<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title> 朝花夕拾</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/ww.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      
<section class="cover">
    
  <div class="cover-frame">
    <div class="bg-box">
      <img src="/images/cover8.jpg" alt="image frame" />
    </div>
    <div class="cover-inner text-center text-white">
      <h1><a href="/">朝花夕拾</a></h1>
      <div id="subtitle-box">
        
        <span id="subtitle"></span>
        
      </div>
      <div>
        
      </div>
    </div>
  </div>
  <div class="cover-learn-more">
    <a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
  </div>
</section>



<script src="https://cdn.staticfile.org/typed.js/2.0.12/typed.min.js"></script>


<!-- Subtitle -->

  <script>
    try {
      var typed = new Typed("#subtitle", {
        strings: ['', '', ''],
        startDelay: 0,
        typeSpeed: 200,
        loop: true,
        backSpeed: 100,
        showCursor: true
      });
    } catch (err) {
      console.log(err)
    }
  </script>
  
<div id="main">
  <section class="outer">
  
  
  

<div class="notice" style="margin-top:50px">
    <i class="ri-heart-fill"></i>
    <div class="notice-content" id="broad"></div>
</div>
<script type="text/javascript">
    fetch('https://v1.hitokoto.cn')
        .then(response => response.json())
        .then(data => {
            document.getElementById("broad").innerHTML = data.hitokoto;
        })
        .catch(console.error)
</script>

<style>
    .notice {
        padding: 20px;
        border: 1px dashed #e6e6e6;
        color: #969696;
        position: relative;
        display: inline-block;
        width: 100%;
        background: #fbfbfb50;
        border-radius: 10px;
    }

    .notice i {
        float: left;
        color: #999;
        font-size: 16px;
        padding-right: 10px;
        vertical-align: middle;
        margin-top: -2px;
    }

    .notice-content {
        display: initial;
        vertical-align: middle;
    }
</style>
  
  <article class="articles">
    
    
    
    
    <article
  id="post-GBase8s逻辑日志类型"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8s%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E7%B1%BB%E5%9E%8B/"
    >GBase8s逻辑日志类型</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97%E7%B1%BB%E5%9E%8B/" class="article-date">
  <time datetime="2023-05-10T01:37:17.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="Informix逻辑日志类型"><a href="#Informix逻辑日志类型" class="headerlink" title="Informix逻辑日志类型"></a>Informix逻辑日志类型</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BEGWORK       1           |   /* BEGIN WORK           */                   |   <span class="string">&quot;BEGIN&quot;</span>,            /* 1 */        |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_COMWORK       2           |   /* COMMIT WORK          */                   |   <span class="string">&quot;COMMIT&quot;</span>,           /* 2 */        |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ROLWORK       3           |   /* ROLLBACK WORK        */                   |   <span class="string">&quot;ROLLBACK&quot;</span>,         /* 3 */        |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BEGCOM        4           |   /* begin to COMMIT      */                   |   <span class="string">&quot;BEGCOM&quot;</span>,           /* 4 */        |</span></span><br><span class="line">/*#define unused        5            |                          */                    |   &quot;UNUSED5&quot;,          /* 5 */        |</span><br><span class="line">/*#define unused        6            |                          */                    |   &quot;UNUSED6&quot;,          /* 6 */        |</span><br><span class="line">/*#define unused        7            |                          */                    |   &quot;UNUSED7&quot;,          /* 7 */        |</span><br><span class="line">/*#define unused        8            |                          */                    |   &quot;UNUSED8&quot;,          /* 8 */        |</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_VERSION       9           |   /* version              */                   |   <span class="string">&quot;VERSION&quot;</span>,          /* 9 */        |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_SVPOINT      10           |   /* savepoint            */                   |   <span class="string">&quot;SVPOINT&quot;</span>,          /* 10 */       |</span></span><br><span class="line">/*#define unused       11            |                          */                    |   &quot;UNUSED11&quot;,         /* 11 */       |</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BUILD        12           |   /* build new file       */                   |   <span class="string">&quot;BUILD&quot;</span>,            /* 12 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ERASE        13           |   /* erase old file       */                   |   <span class="string">&quot;ERASE&quot;</span>,            /* 13 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CINDEX       14           |   /* create index         */                   |   <span class="string">&quot;CINDEX&quot;</span>,           /* 14 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CLUSIDX      15           |   /* create clustered index */                 |   <span class="string">&quot;CLUSIDX&quot;</span>,          /* 15 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DINDEX       16           |   /* drop index           */                   |   <span class="string">&quot;DINDEX&quot;</span>,           /* 16 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_UNIQID       17           |   /* unique <span class="built_in">id</span>            */                   |   <span class="string">&quot;UNIQID&quot;</span>,           /* 17 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RBSVPT       18           |   /* rollback to savepoint */                  |   <span class="string">&quot;RBSVPT&quot;</span>,           /* 18 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PNSIZES      19           |   /* partition size       */                   |   <span class="string">&quot;PNSIZES&quot;</span>,          /* 19 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_LOGFILE      20           |   /* <span class="built_in">log</span> file number      */                   |   <span class="string">&quot;LOGFILE&quot;</span>,          /* 20 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ADDDBS       21           |   /* create dbspace       */                   |   <span class="string">&quot;ADDDBS&quot;</span>,           /* 21 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DRPDBS       22           |   /* drop dbspace         */                   |   <span class="string">&quot;DRPDBS&quot;</span>,           /* 22 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ADDCHK       23           |   /* add chunk            */                   |   <span class="string">&quot;ADDCHK&quot;</span>,           /* 23 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DRPCHK       24           |   /* drop chunk           */                   |   <span class="string">&quot;DRPCHK&quot;</span>,           /* 24 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ADDLOG       25           |   /* add logical <span class="built_in">log</span>      */                   |   <span class="string">&quot;ADDLOG&quot;</span>,           /* 25 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DRPLOG       26           |   /* drop logical <span class="built_in">log</span>     */                   |   <span class="string">&quot;DRPLOG&quot;</span>,           /* 26 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_UNDO         27           |   /* rollback undo record */                   |   <span class="string">&quot;UNDO&quot;</span>,             /* 27 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ADDITEM      28           |   /* add item to index    */                   |   <span class="string">&quot;ADDITEM&quot;</span>,          /* 28 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DELITEM      29           |   /* del item from index  */                   |   <span class="string">&quot;DELITEM&quot;</span>,          /* 29 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BSPADD       30           |   /* add BlobSpace        */                   |   <span class="string">&quot;BSPADD&quot;</span>,           /* 30 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DRPBSP       31           |   /* drop BlobSpace       */                   |   <span class="string">&quot;DRPBSP&quot;</span>,           /* 31 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BLDCL        32           |   /* build partition with column list */       |   <span class="string">&quot;BLDCL&quot;</span>,            /* 32 */       |</span></span><br><span class="line">/*#define unused       33            |                          */                    |   &quot;UNUSED33&quot;,         /* 33 */       |</span><br><span class="line">/*#define unused       34            |                          */                    |   &quot;UNUSED34&quot;,         /* 34 */       |</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BFRMAP       35           |   /* BLOB free map change */                   |   <span class="string">&quot;BFRMAP&quot;</span>,           /* 35 */       |</span></span><br><span class="line">/*#define unused       36            |                          */                    |   &quot;UNUSED36&quot;,         /* 36 */       |</span><br><span class="line">/*#define unused       37            |                          */                    |   &quot;UNUSED37&quot;,         /* 37 */       |</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PBINSERT     38           |   /* PNBLOB insert                */           |   <span class="string">&quot;PBINSERT&quot;</span>,         /* 38 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PBDELETE     39           |   /* PNBLOB delete                */           |   <span class="string">&quot;PBDELETE&quot;</span>,         /* 39 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HINSERT      40           |   /* home insert */                            |   <span class="string">&quot;HINSERT&quot;</span>,          /* 40 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HDELETE      41           |   /* home delete */                            |   <span class="string">&quot;HDELETE&quot;</span>,          /* 41 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HUPBEF       42           |   /* home update before */                     |   <span class="string">&quot;HUPBEF&quot;</span>,           /* 42 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HUPAFT       43           |   /* home update after */                      |   <span class="string">&quot;HUPAFT&quot;</span>,           /* 43 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RINSERT      44           |   /* remainder insert */                       |   <span class="string">&quot;RINSERT&quot;</span>,          /* 44 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RDELETE      45           |   /* remainder delete */                       |   <span class="string">&quot;RDELETE&quot;</span>,          /* 45 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RUPBEF       46           |   /* remainder update before */                |   <span class="string">&quot;RUPBEF&quot;</span>,           /* 46 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RUPAFT       47           |   /* remainder update after */                 |   <span class="string">&quot;RUPAFT&quot;</span>,           /* 47 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_LCKLVL       48           |   /* locking mode */                           |   <span class="string">&quot;LCKLVL&quot;</span>,           /* 48 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CHGPHYSLOG   49           |   /* change physical <span class="built_in">log</span> location */           |   <span class="string">&quot;CHPHYLOG&quot;</span>,         /* 49 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTEXTEND     50           |   /* partition extend */                       |   <span class="string">&quot;PTEXTEND&quot;</span>,         /* 50 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CHALLOC      51           |   /* chunk extent allocation */                |   <span class="string">&quot;CHALLOC&quot;</span>,          /* 51 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CHFREE       52           |   /* chunk extent free */                      |   <span class="string">&quot;CHFREE&quot;</span>,           /* 52 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CHCOMBINE    53           |   /* chunk extent combine */                   |   <span class="string">&quot;CHCOMBIN&quot;</span>,         /* 53 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CHSPLIT      54           |   /* chunk extent <span class="built_in">split</span> */                     |   <span class="string">&quot;CHSPLIT&quot;</span>,          /* 54 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PERASE       55           |   /* pre erase old file   */                   |   <span class="string">&quot;PERASE&quot;</span>,           /* 55 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PDINDEX      56           |   /* pre drop index */                         |   <span class="string">&quot;PDINDEX&quot;</span>,          /* 56 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BTCPYBCK     57           |   /* copyback key from child to parent */      |   <span class="string">&quot;BTCPYBCK&quot;</span>,         /* 57 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BTSPLIT      58           |   /* <span class="built_in">split</span> btree node */                       |   <span class="string">&quot;BTSPLIT&quot;</span>,          /* 58 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BTMERGE      59           |   /* merge btree nodes */                      |   <span class="string">&quot;BTMERGE&quot;</span>,          /* 59 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BTSHUFFLE    60           |   /* shuffle btree nodes */                    |   <span class="string">&quot;BTSHUFFL&quot;</span>,         /* 60 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BADIDX       61           |   /* bad index            */                   |   <span class="string">&quot;BADIDX&quot;</span>,           /* 61 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CLR          62           |   /* compensation <span class="built_in">log</span> record */                |   <span class="string">&quot;CLR&quot;</span>,              /* 62 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_IDXFLAGS     63           |   /* modify key.k_flags */                     |   <span class="string">&quot;IDXFLAGS&quot;</span>,         /* 63 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_COLREPAIR    64           |   /* column repair */                          |   <span class="string">&quot;COLREPAI&quot;</span>,         /* 64 */       |</span></span><br><span class="line">/*#define unused       65            |                          */                    |   &quot;UNUSED65&quot;,         /* 65 */       |</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CKPOINT      66           |   /* checkpoint           */                   |   <span class="string">&quot;CKPOINT&quot;</span>,          /* 66 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BEGPREP      67           |   /* I-STAR(C) begins prepare */               |   <span class="string">&quot;BEGPREP&quot;</span>,          /* 67 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PREPARE      68           |   /* I-STAR(S) prepared to commit */           |   <span class="string">&quot;PREPARE&quot;</span>,          /* 68 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_XAPREPARE    69           |   /* XA prepared to commit */                  |   <span class="string">&quot;XAPREPARE&quot;</span>,        /* 69 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ENDTRANS     70           |   /* End of TX, TX can be forgotten */         |   <span class="string">&quot;ENDTRANS&quot;</span>,         /* 70 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_TABLOCKS     71           |   /* list of tblspace XLOCKS */                |   <span class="string">&quot;TABLOCKS&quot;</span>,         /* 71 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HEURTX       72           |   /* TX being heuristically completed */       |   <span class="string">&quot;HEURTX&quot;</span>,           /* 72 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HUPDATE      73           |   /* home page diffs (delta logrec) */         |   <span class="string">&quot;HUPDATE&quot;</span>,          /* 73 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RUPDATE      74           |   /* remainder page diffs (delta logrec)*/     |   <span class="string">&quot;RUPDATE&quot;</span>,          /* 74 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTRENAME     75           |                                                |   <span class="string">&quot;PTRENAME&quot;</span>,         /* 75 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RSVEXTEND    76           |                                                |   <span class="string">&quot;RSVEXTND&quot;</span>,         /* 76 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_UNDOBLDCL    77           |   /* media error, can<span class="string">&#x27;t do table drop */       |   &quot;UNDBLDCL&quot;,         /* 77 */       |</span></span></span><br><span class="line">/*#define unused       78            |                          */                    |   &quot;UNUSED78&quot;,         /* 78 */       |</span><br><span class="line">/*#define unused       79            |                          */                    |   &quot;UNUSED79&quot;,         /* 79 */       |</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">define LG_REVERT       80           |   /* reversion progress           */           |   &quot;REVERT&quot;,           /* 80 */       |</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">define LG_DERASE       81           |   /* drop partition in down dbspace */         |   &quot;DERASE&quot;,           /* 81 */       |</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">define LG_PNLOCKID     82           |   /* change partition&#x27;</span>s lockid    */           |   <span class="string">&quot;PNLOCKID&quot;</span>,         /* 82 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_REPLICATE    83           |   /* replication */                            |   <span class="string">&quot;REPLICATE&quot;</span>,        /* 83 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_LTAPPEND     84           |   /* Light Append */                           |   <span class="string">&quot;LTAPPEND&quot;</span>,         /* 84 */       |</span></span><br><span class="line">/*#define unused       85            |                          */                    |   &quot;UNUSED85&quot;,         /* 85 */       |</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PNOCTPTNM    86           |   /* checkpoint record */                      |   <span class="string">&quot;PNOCTPTNM&quot;</span>,        /* 86 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ARCINFO      87           |   /* arcinfo and logbu record */               |   <span class="string">&quot;ARCINFO&quot;</span>,          /* 87 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PGMODE       88           |   /* mode of page changed */                   |   <span class="string">&quot;PGMODE&quot;</span>,           /* 88 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BMAPFULL     89           |   /* bitmap modified to mark pages full */     |   <span class="string">&quot;BMAPFULL&quot;</span>,         /* 89 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BMAP2TO4     90           |   /* bitmap changed from 2-bit to 4-bit */     |   <span class="string">&quot;BMAP2TO4&quot;</span>,         /* 90 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTCOLUMN     91           |   /* add special columns to partition */       |   <span class="string">&quot;PTCOLUMN&quot;</span>,         /* 91 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTADESC      92           |   /* add alter descriptors to partition */     |   <span class="string">&quot;PTADESC&quot;</span>,          /* 92 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTALTER      93           |   /* partition altered */                      |   <span class="string">&quot;PTALTER&quot;</span>,          /* 93 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PGALTER      94           |   /* page altered <span class="keyword">in</span> place */                  |   <span class="string">&quot;PGALTER&quot;</span>,          /* 94 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ALTERDONE    95           |   /* specific alter physically finished */     |   <span class="string">&quot;ALTERDONE&quot;</span>,        /* 95 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_MVIDXND      96           |   /* move index node <span class="keyword">for</span> inplace alter */      |   <span class="string">&quot;MVIDXND&quot;</span>,          /* 96 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_UNIQ8ID      97           |   /* serial 8 value */                         |   <span class="string">&quot;UNIQ8ID&quot;</span>,          /* 97 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_REFID        98           |   /* reference value */                        |   <span class="string">&quot;REFID&quot;</span>,            /* 98 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ALLOCGENPG   99           |   /* allocate a generic page */                |   <span class="string">&quot;ALLOCGENPG&quot;</span>,       /* 99 */       |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_FREEGENPG    100          |   /* free a generic page */                    |   <span class="string">&quot;FREEGENPG&quot;</span>,        /* 100 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_OLD72CKPOINT 101          |   /* 7.2 checkpoint record */                  |   <span class="string">&quot;OLD72CKPOINT&quot;</span>,     /* 101 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ISOSPCOMMIT  102          |   /* Log an isolated save point commit */      |   <span class="string">&quot;ISOSPCOMMIT&quot;</span>,      /* 102 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HSH_PGOVFL   103          |   /* creation of SHA overflow page */          |   <span class="string">&quot;HASH_PGOVFL&quot;</span>,      /* 103 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HSH_RMOVFL   104          |   /* removal of SHA overflow page */           |   <span class="string">&quot;HASH_RMOVFL&quot;</span>,      /* 104 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_HSH_SLOVFL   105          |   /* mark a SHA home slot as overflowed */     |   <span class="string">&quot;HASH_SLOVFL&quot;</span>,      /* 105 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTALTOLDKEYD 106          |   /* Alter table- old key descriptors*/        |   <span class="string">&quot;PTALTOLDKEYD&quot;</span>,     /* 106 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTALTNEWKEYD 107          |   /* Alter table- new key descriptors*/        |   <span class="string">&quot;PTALTNEWKEYD&quot;</span>,     /* 107 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DPT          108          |   /* Dirty pages table */                      |   <span class="string">&quot;DPT&quot;</span>,              /* 108 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ALTSPCOLSOLD 109          |   /* Alter table- old special column descr */  |   <span class="string">&quot;ALTSPCOLSOLD&quot;</span>,     /* 109 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ALTSPCOLSNEW 110          |   /* Alter table- new special column descr */  |   <span class="string">&quot;ALTSPCOLSNEW&quot;</span>,     /* 110 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_BCMODE       111          |   /* Big chunk mode changed */                 |   <span class="string">&quot;BCMODE&quot;</span>,           /* 111 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DRSYNC       112          |   /* DR Sync used during index transfer */     |   <span class="string">&quot;DRSYNC&quot;</span>,           /* 112 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_RENDBS       113          |   /* space is Renamed */                       |   <span class="string">&quot;RENDBS&quot;</span>,           /* 113 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ALTTABTYPE   114          |   /* Alter table <span class="built_in">type</span> - recovery status        |   <span class="string">&quot;ALTTABTYPE&quot;</span>,       /* 114 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PRE94TO73CKPOINT     115  |   /* 7.3, 9.1, 9.2 or 9.3 checkpoint record */ |   <span class="string">&quot;PRE94TO73CKPOINT&quot;</span>, /* 115 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CDRALTER     116          |   /* CDR alter mode */                         |   <span class="string">&quot;CDRALTER&quot;</span>,         /* 116 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_ADDBPOOL     117          |   /* add a new buffer pool online */           |   <span class="string">&quot;ADDBPOOL&quot;</span>,         /* 117 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTRUNCATE    118          |   /* Pre-<span class="built_in">truncate</span> <span class="built_in">log</span> record */                |   <span class="string">&quot;PTRUNCATE&quot;</span>,        /* 118 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_TRUNCATE     119          |   /* Truncate complete <span class="built_in">log</span> record */           |   <span class="string">&quot;TRUNCATE&quot;</span>,         /* 119 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_DREXEFUNC    120          |   /* DR Execute Function on secondary */       |   <span class="string">&quot;DREXEFUNC&quot;</span>,        /* 120 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PNFLAGS      121          |   /* Partition flags change */                 |   <span class="string">&quot;PNFLAGS&quot;</span>,          /* 121 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_IDXPAGE      122          |   /* index page */                             |   <span class="string">&quot;IDXPAGE&quot;</span>,          /* 122 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_IDXEND       123          |   /* end of index pages */                     |   <span class="string">&quot;IDXEND&quot;</span>,           /* 123 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_CONFIG       124          |   /* config parameter */                       |   <span class="string">&quot;CONFIG&quot;</span>,           /* 124 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PRE1150TO94CKPOINT   125  |   /* 9.4, 10.00, 11.10 checkpoint record */    |   <span class="string">&quot;PRE1150TO94CKPOINT&quot;</span>, /* 125 */    |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_UNIQID_BIGSERIAL     126  |           /* Bigserial uniqid */               |   <span class="string">&quot;UNIQID_BIGSERIAL&quot;</span>, /* 126 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_COMPDICTCR   127          |   /* compression dictionary created */         |   <span class="string">&quot;COMPDICTCR&quot;</span>,       /* 127 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_COMPDICTDROP 128          |   /* compression dictionary dropped */         |   <span class="string">&quot;COMPDICTDROP&quot;</span>,     /* 128 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_COMPDICTTAB  129          |   /* compression dictionary table */           |   <span class="string">&quot;COMPDICTTAB&quot;</span>,      /* 129 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PTSHRINK     130          |   /* Free unused space at end of partn */      |   <span class="string">&quot;PTSHRINK&quot;</span>,         /* 130 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_COMPPZERO     131         |   /* page zero change <span class="keyword">for</span> compression */       |   <span class="string">&quot;COMPPZERO&quot;</span>,        /* 131 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PNCOMPDICTADD 132         |   /* compress partition */                     |   <span class="string">&quot;PNCOMPDICTADD&quot;</span>,    /* 132 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_PNCOMPDICTDROP 133        |   /* uncompress partition */                   |   <span class="string">&quot;PNCOMPDICTDROP&quot;</span>    /* 133 */      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_XASTART       134         |                                                |                                      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define LG_XAEND          135        |                                                |                                      |</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define MAXLOGTYPES     136          |                                                |                                      |</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/level3/" rel="tag">level3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%80%BB%E8%BE%91%E6%97%A5%E5%BF%97/" rel="tag">逻辑日志</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s集群管理程序WeiCM介绍和部署步骤"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8s%E9%9B%86%E7%BE%A4%E7%AE%A1%E7%90%86%E7%A8%8B%E5%BA%8FWeiCM%E4%BB%8B%E7%BB%8D%E5%92%8C%E9%83%A8%E7%BD%B2%E6%AD%A5%E9%AA%A4/"
    >GBase8s集群管理程序WeiCM介绍和部署步骤</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E9%9B%86%E7%BE%A4%E7%AE%A1%E7%90%86%E7%A8%8B%E5%BA%8FWeiCM%E4%BB%8B%E7%BB%8D%E5%92%8C%E9%83%A8%E7%BD%B2%E6%AD%A5%E9%AA%A4/" class="article-date">
  <time datetime="2023-05-10T01:36:01.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/Develop/">Develop</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="GBase8s集群管理程序介绍和部署"><a href="#GBase8s集群管理程序介绍和部署" class="headerlink" title="GBase8s集群管理程序介绍和部署"></a>GBase8s集群管理程序介绍和部署</h1><p>​		说明，WeiCM，WeiDbManager ，WeiOsManager 这些程序暂时这么命名，待公司收并后，可统一改名为：GBaseCM，GBaseDbManager ，GBaseOsManager。</p>
<h2 id="新旧CM对比介绍"><a href="#新旧CM对比介绍" class="headerlink" title="新旧CM对比介绍"></a>新旧CM对比介绍</h2><blockquote>
<h3 id="自带Connection-Manager："><a href="#自带Connection-Manager：" class="headerlink" title="自带Connection Manager："></a>自带Connection Manager：</h3></blockquote>
<ul>
<li>数据库自带的集群管理程序 Connection Manager 弊端： <ul>
<li>没有vip，需要代理或者转发。</li>
<li>源码复杂，并且谨慎有余灵活不足，不能满足客户特殊需求。</li>
</ul>
</li>
</ul>
<blockquote>
<h3 id="新开发的WeiCM："><a href="#新开发的WeiCM：" class="headerlink" title="新开发的WeiCM："></a>新开发的WeiCM：</h3></blockquote>
<ul>
<li><p>组件如下：</p>
<ul>
<li><p><strong>WeiDbManager</strong> ：对DB实施操作的代理接口，提供数据库启停，角色切换，集群关系定义接口。</p>
</li>
<li><p><strong>WeiOsManager</strong> ：对OS实施操作的代理接口，提供vip绑定解绑接口。</p>
</li>
<li><p><strong>WeiCM</strong> ： 负责集群定义，负责节点自恢复，负责节点角色切换，负责主角色选举，负责VIP切换。</p>
<p>( WeiCM有windows版本和Linux版，分别是：<strong>WeiCM.exe 和 WeiCM</strong> )</p>
</li>
</ul>
</li>
</ul>
<h2 id="部署架构图"><a href="#部署架构图" class="headerlink" title="部署架构图"></a>部署架构图</h2><ul>
<li>部署架构图 <img src="D:\Lenovo\Documents\0397f16193064d7db8ef85f0320c46c8.png" alt="在这里插入图片描述"></li>
</ul>
<p>下文示例中：</p>
<p>​	集群CM节点：     1.1.1.1                               (<strong>运行程序 WeiCM.exe 或 WeiCM</strong>)；</p>
<p>​	Database节点一：1.1.1.2                               (<strong>运行程序 WeiOsManager和WeiDbManager</strong>**)；</p>
<p>​	Database节点二：1.1.1.3                               (<strong>运行程序 WeiOsManager和WeiDbManager</strong>**)；</p>
<h2 id="部署前提条件"><a href="#部署前提条件" class="headerlink" title="部署前提条件"></a>部署前提条件</h2><ul>
<li>Database节点一和Database节点二之间gbasedbt用户的ssh信任关系配置完成。</li>
<li>Database节点一和Database节点二之间RSS集群管理配置完成。</li>
</ul>
<h2 id="WeiCM部署步骤"><a href="#WeiCM部署步骤" class="headerlink" title="WeiCM部署步骤"></a>WeiCM部署步骤</h2><p>​		说明：下文没有说明在哪个节点操作，就是在两个Database节点都要操作。</p>
<h3 id="步骤00：清理残留进程"><a href="#步骤00：清理残留进程" class="headerlink" title="步骤00：清理残留进程"></a>步骤00：清理残留进程</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ps -ef |grep WeiOsManager |grep -v grep |awk &#x27;&#123;print &quot;kill -9 &quot;$2&#125;&#x27;|sh</span><br><span class="line">ps -ef |grep WeiDbManager |grep -v grep |awk &#x27;&#123;print &quot;kill -9 &quot;$2&#125;&#x27;|sh</span><br></pre></td></tr></table></figure>



<h3 id="步骤01：上传程序包到两个DB节点"><a href="#步骤01：上传程序包到两个DB节点" class="headerlink" title="步骤01：上传程序包到两个DB节点"></a>步骤01：上传程序包到两个DB节点</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">root用户操作</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">准备目录</span></span><br><span class="line">rm -fr   /tmp/WEICMLOG/</span><br><span class="line">rm -fr   /home/gbase/sysInfo</span><br><span class="line">rm -fr    /opt/gbase/sysInfo</span><br><span class="line">mkdir -p /home/gbase/sysInfo/WeiShell</span><br><span class="line">mkdir -p  /opt/gbase/sysInfo/WeiShell</span><br><span class="line">chown -R gbasedbt:gbasedbt /home/gbase/sysInfo</span><br><span class="line">chown -R gbasedbt:gbasedbt  /opt/gbase/sysInfo</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">上传目录</span></span><br><span class="line">mkdir -p /opt/weicm/soft</span><br><span class="line">cd /opt/weicm/soft</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">上传newWeiCM.zip到这个目录下，然后解压</span></span><br><span class="line">unzip newWeiCM.zip</span><br><span class="line">mv 更新-加入token身份验证-添加Linux版本 newcm</span><br><span class="line">cd /opt/weicm/soft/newcm</span><br><span class="line">chmod 755 Wei*</span><br><span class="line">chmod 755 *sh</span><br></pre></td></tr></table></figure>



<h3 id="步骤02：WeiOsManager-部署"><a href="#步骤02：WeiOsManager-部署" class="headerlink" title="步骤02：WeiOsManager 部署"></a>步骤02：WeiOsManager 部署</h3><p>使用root用户复制粘贴全部下文：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">cd /opt/weicm/soft/newcm</span><br><span class="line">cp WeiOsManager /opt/gbase/sysInfo/WeiShell/</span><br><span class="line">cp -r templates /opt/gbase/sysInfo/</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动样例,这里不要操作，后面会配置进开机自启：</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="built_in">nohup</span> ./WeiOsManager -i 1.1.1.6 -d eth1 -l 1.1.1.2 &amp;</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="built_in">nohup</span> ./WeiOsManager -i 1.1.1.6 -d eth1 -l 1.1.1.3 &amp;</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">手动绑定IP样例，这里不要操作</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ip addr add 1.1.1.6/24 dev eth1</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ip addr del 1.1.1.6/24 dev eth1</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="步骤03：数据库添加别名"><a href="#步骤03：数据库添加别名" class="headerlink" title="步骤03：数据库添加别名"></a>步骤03：数据库添加别名</h3><p>使用gbasedbt用户复制粘贴全部下文：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ONCONFIG 添加别名</span></span><br><span class="line">sed -i &#x27;s/^DBSERVERALIASES.*/DBSERVERALIASES gbase/&#x27; /opt/gbase/etc/$ONCONFIG</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">SQLHOSTS 添加别名</span></span><br><span class="line">cat &gt;&gt; /opt/gbase/etc/sqlhosts &lt;&lt; EOF</span><br><span class="line"></span><br><span class="line">gbase    onsoctcp 0.0.0.0  9089</span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">重启数据库</span></span><br><span class="line">onmode -ky</span><br><span class="line">onclean -ky</span><br><span class="line">oninit -v</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看别名监听已经启动</span></span><br><span class="line">netstat -lntp |grep 9089</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="步骤04：WeiDbManager-部署"><a href="#步骤04：WeiDbManager-部署" class="headerlink" title="步骤04：WeiDbManager 部署"></a>步骤04：WeiDbManager 部署</h3><p>使用gbasedbt用户复制粘贴全部下文：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">su - gbasedbt</span></span><br><span class="line">cd /opt/weicm/soft/newcm</span><br><span class="line">cp WeiDbManager   /home/gbase/sysInfo/WeiShell/</span><br><span class="line">cp pingtest.sh    /home/gbase/sysInfo/WeiShell/</span><br><span class="line">cp GetNodeInfo.sh /home/gbase/sysInfo/WeiShell/</span><br><span class="line">cp -r templates   /home/gbase/sysInfo/</span><br></pre></td></tr></table></figure>





<h3 id="步骤05：WeiCM-部署"><a href="#步骤05：WeiCM-部署" class="headerlink" title="步骤05：WeiCM 部署"></a>步骤05：WeiCM 部署</h3><p>​		说明：步骤05的所有操作在1.1.1.1主机上用root用户执行：</p>
<blockquote>
<p>复制WeiCM程序到管理节点，并改名为WeiCMAAABBBCCC</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">rm -fr   /opt/gbase/sysInfo/CM/</span><br><span class="line">mkdir -p /opt/gbase/sysInfo/CM/</span><br><span class="line"></span><br><span class="line">cd /opt/gbase/sysInfo/CM/</span><br><span class="line">scp 1.1.1.2:/opt/weicm/soft/newcm/WeiCM ./WeiCMAAABBBCCC</span><br><span class="line">scp 1.1.1.2:/opt/weicm/soft/newcm/runWeiCMAAABBBCCC.sh ./runWeiCMAAABBBCCC.sh</span><br></pre></td></tr></table></figure>


<blockquote>
<p>创建配置文件NodeBase.json</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">cd /opt/gbase/sysInfo/CM/</span><br><span class="line">cat &gt; /opt/gbase/sysInfo/CM/NodeBase.json &lt;&lt; EOF</span><br><span class="line">[</span><br><span class="line">    &#123;</span><br><span class="line">        &quot;ServName&quot;: &quot;gbase001&quot;,</span><br><span class="line">        &quot;ServIP&quot;: &quot;1.1.1.2&quot;,</span><br><span class="line">        &quot;HostIP&quot;: &quot;1.1.1.2&quot;,</span><br><span class="line">        &quot;ServPort&quot;: &quot;9089&quot;,</span><br><span class="line">        &quot;HostPort&quot;: &quot;9089&quot;,</span><br><span class="line">        &quot;ServInfoPort&quot;: &quot;6060&quot;,</span><br><span class="line">        &quot;HostInfoPort&quot;: &quot;6060&quot;,</span><br><span class="line">        &quot;Listenip&quot;: &quot;1.1.1.2&quot;,</span><br><span class="line">        &quot;Listenport&quot;: &quot;6061&quot;</span><br><span class="line">    &#125;,</span><br><span class="line">    &#123;</span><br><span class="line">        &quot;ServName&quot;: &quot;gbase002&quot;,</span><br><span class="line">        &quot;ServIP&quot;: &quot;1.1.1.3&quot;,</span><br><span class="line">        &quot;HostIP&quot;: &quot;1.1.1.3&quot;,</span><br><span class="line">        &quot;ServPort&quot;: &quot;9089&quot;,</span><br><span class="line">        &quot;HostPort&quot;: &quot;9089&quot;,</span><br><span class="line">        &quot;ServInfoPort&quot;: &quot;6060&quot;,</span><br><span class="line">        &quot;HostInfoPort&quot;: &quot;6060&quot;,</span><br><span class="line">        &quot;Listenip&quot;: &quot;1.1.1.3&quot;,</span><br><span class="line">        &quot;Listenport&quot;: &quot;6061&quot;</span><br><span class="line">    &#125;</span><br><span class="line">]</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>



<ul>
<li>NodeBase.json文件说明（为容器方式部署预留了端口映射）根据你都需要修改json字段值： <ul>
<li>实例名 （同时用作容器名）</li>
<li>数据库监听IP</li>
<li>宿主机IP</li>
<li>数据库监听端口</li>
<li>宿主机映射数据库监听端口</li>
<li>信息采集及WeiDbManager端口</li>
<li>宿主机映射信息采集及WeiDbManager端口</li>
<li>VIP管理WeiOsManager监听IP</li>
<li>VIP管理WeiOsManager监听端口</li>
</ul>
</li>
</ul>
<h2 id="配置开机自启动"><a href="#配置开机自启动" class="headerlink" title="配置开机自启动"></a>配置开机自启动</h2><h3 id="使用root用户复制粘贴全部下文：三个节点都做"><a href="#使用root用户复制粘贴全部下文：三个节点都做" class="headerlink" title="使用root用户复制粘贴全部下文：三个节点都做"></a>使用root用户复制粘贴全部下文：三个节点都做</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">cat &gt; /lib/systemd/system/rc-local.service &lt;&lt;EOF</span><br><span class="line"></span><br><span class="line">[Unit]</span><br><span class="line">Description=/etc/rc.local Compatibility</span><br><span class="line">Documentation=man:systemd-rc-local-generator(8)</span><br><span class="line">ConditionFileIsExecutable=/etc/rc.local</span><br><span class="line">After=network.target</span><br><span class="line"></span><br><span class="line">[Service]</span><br><span class="line">Type=forking</span><br><span class="line">ExecStart=/etc/rc.local start</span><br><span class="line">TimeoutSec=0</span><br><span class="line">RemainAfterExit=yes</span><br><span class="line">GuessMainPID=no</span><br><span class="line"></span><br><span class="line">[Install]</span><br><span class="line">WantedBy=multi-user.target  </span><br><span class="line">Alias=rc-local.service</span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line">ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/</span><br></pre></td></tr></table></figure>

<h3 id="1-1-1-2DB节点的-x2F-etc-x2F-rc-local-配置"><a href="#1-1-1-2DB节点的-x2F-etc-x2F-rc-local-配置" class="headerlink" title="1.1.1.2DB节点的 &#x2F;etc&#x2F;rc.local 配置"></a>1.1.1.2DB节点的 &#x2F;etc&#x2F;rc.local 配置</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">1.1.1.2主机</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">注意：eth网卡名称改成你自己的</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">注意：1.1.1.1ping网关改成你自己的</span></span><br><span class="line">cat &gt; /etc/rc.local &lt;&lt; EOF</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/sh</span></span><br><span class="line"></span><br><span class="line">mkdir /tmp/WEICMLOG/</span><br><span class="line">chmod 777 /tmp/WEICMLOG</span><br><span class="line"></span><br><span class="line">cd /opt/gbase/sysInfo/WeiShell</span><br><span class="line">./WeiOsManager -i 1.1.1.6 -d ens33 -l 1.1.1.2 &gt; /tmp/WEICMLOG/WeiOsManager.log 2&gt;&amp;1 &amp; </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">su - gbasedbt -c &quot;cd /home/gbase/sysInfo/WeiShell; ./WeiDbManager &gt; /tmp/WEICMLOG/WeiDbManager.log 2&gt;&amp;1 &amp; &quot;  </span><br><span class="line">su - gbasedbt -c &quot;cd /home/gbase/sysInfo/WeiShell; ./pingtest.sh  1.1.1.1 &gt; /tmp/WEICMLOG/pingtest.log 2&gt;&amp;1 &amp; &quot;</span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line">chmod 755  /etc/rc.local</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="1-1-1-3DB节点的-x2F-etc-x2F-rc-local-配置"><a href="#1-1-1-3DB节点的-x2F-etc-x2F-rc-local-配置" class="headerlink" title="1.1.1.3DB节点的 &#x2F;etc&#x2F;rc.local 配置"></a>1.1.1.3DB节点的 &#x2F;etc&#x2F;rc.local 配置</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">1.1.1.3主机，注意eth网卡名称改成你自己的</span></span><br><span class="line">cat &gt; /etc/rc.local &lt;&lt; EOF</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/sh</span></span><br><span class="line"></span><br><span class="line">mkdir /tmp/WEICMLOG/</span><br><span class="line">chmod 777 /tmp/WEICMLOG</span><br><span class="line"></span><br><span class="line">cd /opt/gbase/sysInfo/WeiShell</span><br><span class="line">./WeiOsManager -i 1.1.1.6 -d ens33 -l 1.1.1.3 &gt; /tmp/WEICMLOG/WeiOsManager.log 2&gt;&amp;1 &amp; </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">su - gbasedbt -c &quot;cd /home/gbase/sysInfo/WeiShell; ./WeiDbManager &gt; /tmp/WEICMLOG/WeiDbManager.log 2&gt;&amp;1 &amp; &quot;  </span><br><span class="line">su - gbasedbt -c &quot;cd /home/gbase/sysInfo/WeiShell; ./pingtest.sh  1.1.1.1 &gt; /tmp/WEICMLOG/pingtest.log 2&gt;&amp;1 &amp; &quot;</span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line">chmod 755  /etc/rc.local</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="1-1-1-1CM节点的-x2F-etc-x2F-rc-local-配置"><a href="#1-1-1-1CM节点的-x2F-etc-x2F-rc-local-配置" class="headerlink" title="1.1.1.1CM节点的 &#x2F;etc&#x2F;rc.local 配置"></a>1.1.1.1CM节点的 &#x2F;etc&#x2F;rc.local 配置</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">1.1.1.1主机</span></span><br><span class="line">cat &gt; /etc/rc.local &lt;&lt; EOF</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/sh</span></span><br><span class="line"></span><br><span class="line">mkdir /tmp/WEICMLOG/</span><br><span class="line">chmod 777 /tmp/WEICMLOG</span><br><span class="line"></span><br><span class="line">cd /opt/gbase/sysInfo/CM/</span><br><span class="line">./runWeiCMAAABBBCCC.sh &gt; /tmp/WEICMLOG/runWeiCMAAABBBCCC.log 2&gt;&amp;1 &amp; </span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line">chmod 755  /etc/rc.local</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="设置网关IP"><a href="#设置网关IP" class="headerlink" title="设置网关IP"></a>设置网关IP</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sed -i &#x27;s/ipway=$1/ipway=1.1.1.1/&#x27; /home/gbase/sysInfo/WeiShell/GetNodeInfo.sh</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="重启所有节点操作系统"><a href="#重启所有节点操作系统" class="headerlink" title="重启所有节点操作系统"></a>重启所有节点操作系统</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">reboot</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="第一次启动1-1-1-2主DB节点服务"><a href="#第一次启动1-1-1-2主DB节点服务" class="headerlink" title="第一次启动1.1.1.2主DB节点服务"></a>第一次启动1.1.1.2主DB节点服务</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">ip addr add 1.1.1.6/24 dev ens33</span><br><span class="line">ip a |grep 1.1.1.6</span><br><span class="line">su - gbasedbt</span><br><span class="line">oninit -v</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="等待整个集群自动启动会恢复完成"><a href="#等待整个集群自动启动会恢复完成" class="headerlink" title="等待整个集群自动启动会恢复完成"></a>等待整个集群自动启动会恢复完成</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">cd /tmp/WEICMLOG/</span><br><span class="line">cat pingtest.log</span><br><span class="line">cat WeiDbManager.log</span><br><span class="line">cat WeiOsManager.log</span><br><span class="line">tail -f runWeiCMAAABBBCCC.log</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd /opt/gbase/sysInfo/CM/</span><br><span class="line">tail -f weicm.log</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="部署完成"><a href="#部署完成" class="headerlink" title="部署完成"></a>部署完成</h2><p>​		说明：至此整个集群部署完成，上面的“第一次启动1.1.1.2主节点服务”是应为所有节点数据库都关闭了，为了安全，程序不会做任何操作。如果集群里有只少一个节点活着，就不用手动做上述的这一步操作。</p>
<h2 id="交付应用"><a href="#交付应用" class="headerlink" title="交付应用"></a>交付应用</h2><p>业务连接数据库的服务名： gbase</p>
<p>业务连接数据库的IP为： 1.1.1.6</p>
<p>业务连接数据库的端口为： 9089</p>
<p>业务连接数据库的用户名密码： gbasedbt &#x2F; GBase123</p>
<h1 id="给WeiCM集群扩展备份恢复功能"><a href="#给WeiCM集群扩展备份恢复功能" class="headerlink" title="给WeiCM集群扩展备份恢复功能"></a>给WeiCM集群扩展备份恢复功能</h1><p>​		上述集群已经，基本上可以满足，故障点修复后集群的自动修复还原问题。考虑到集群有可能出现 “逻辑日志滚圈 和 备机重放日志冲突“ 的情况，这种情况下集群自动修复只有依赖备份恢复来完成。所有我对程序进行了进一步完善，给他添加了备机集群不能恢复时的，自动从主机拉取全量备份数据的功能。</p>
<blockquote>
<h3 id="扩展功能部署步骤"><a href="#扩展功能部署步骤" class="headerlink" title="扩展功能部署步骤"></a>扩展功能部署步骤</h3></blockquote>
<p>​			</p>
<h3 id="步骤01：WeiRssResort-部署"><a href="#步骤01：WeiRssResort-部署" class="headerlink" title="步骤01：WeiRssResort 部署"></a>步骤01：WeiRssResort 部署</h3><p>​		使用gbasedbt用户在两个DB节点上部署。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cp /opt/weicm/soft/newcm/WeiRssResort.sh /home/gbase/sysInfo/WeiShell</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="步骤02：配置开机启动"><a href="#步骤02：配置开机启动" class="headerlink" title="步骤02：配置开机启动"></a>步骤02：配置开机启动</h3><p>​		使用root用户在两个DB节点上部署。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">cat &gt;&gt; /etc/rc.local &lt;&lt; EOF</span><br><span class="line"></span><br><span class="line">su - gbasedbt -c &quot;cd /home/gbase/sysInfo/WeiShell; ./WeiRssResort.sh &gt; /tmp/WEICMLOG/WeiRssResort.log 2&gt;&amp;1 &amp; &quot;</span><br><span class="line"></span><br><span class="line">EOF</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h3 id="扩展备份恢复功能部署完成"><a href="#扩展备份恢复功能部署完成" class="headerlink" title="扩展备份恢复功能部署完成"></a>扩展备份恢复功能部署完成</h3><p>​		至此全部部署完成，WeiRssResort会检测所有RSS备机节点，是否日志落下一圈和异常，在RSS备节点无法同步集群日志时，对其做全量恢复并自动搭建集群。</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%87%AA%E7%A0%94/" rel="tag">自研</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%9B%86%E7%BE%A4/" rel="tag">集群</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%AB%98%E5%8F%AF%E7%94%A8/" rel="tag">高可用</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8sMybatis测试用例"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8sMybatis%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B/"
    >GBase8sMybatis测试用例</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8sMybatis%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B/" class="article-date">
  <time datetime="2023-05-10T01:33:32.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="这个测试最新源码存储在"><a href="#这个测试最新源码存储在" class="headerlink" title="这个测试最新源码存储在"></a>这个测试最新源码存储在</h2><p>D:\soft\src\Java\WeiMyBatis</p>
<h2 id="实体类定义"><a href="#实体类定义" class="headerlink" title="实体类定义"></a>实体类定义</h2><p>D:\go\src\java\WeiMyBatis\src\main\java\com\trey\mybatis\pojo\User.java</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.trey.mybatis.pojo;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> lombok.Data;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Data</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">User</span> &#123;</span><br><span class="line">    <span class="keyword">private</span> Integer id;</span><br><span class="line">    <span class="keyword">private</span> String userName;</span><br><span class="line">    <span class="keyword">private</span> String realName;</span><br><span class="line">    <span class="keyword">private</span> String password;</span><br><span class="line">    <span class="keyword">private</span> Integer age;</span><br><span class="line">    <span class="keyword">private</span> Integer dId;</span><br><span class="line"></span><br><span class="line">    User()&#123;&#125;</span><br><span class="line">    <span class="keyword">public</span> <span class="title function_">User</span><span class="params">(Integer idx,String userNamex,String realNamex,String passwordx,Integer agex,Integer dIdx)</span>&#123;</span><br><span class="line">        id=idx;</span><br><span class="line">        userName=userNamex;</span><br><span class="line">        realName=realNamex;</span><br><span class="line">        password=passwordx;</span><br><span class="line">        age=agex;</span><br><span class="line">        dId=dIdx;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> Integer <span class="title function_">getid</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> id;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getuserName</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> userName;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getrealName</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> realName;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">getpassword</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> password;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> Integer <span class="title function_">getage</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> age;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> Integer <span class="title function_">getdId</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> dId;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">toString</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;(&quot;</span>+id.toString()+<span class="string">&quot;,&#x27;&quot;</span>+userName+<span class="string">&quot;&#x27;,&#x27;&quot;</span>+realName+<span class="string">&quot;&#x27;,&#x27;&quot;</span>+password+<span class="string">&quot;&#x27;,&quot;</span>+age+<span class="string">&quot;,&quot;</span>+password+<span class="string">&quot;)&quot;</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="批量造数"><a href="#批量造数" class="headerlink" title="批量造数"></a>批量造数</h2><p>D:\go\src\java\WeiMyBatis\src\main\java\com\trey\mybatis\pojo\UserList.java</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.trey.mybatis.pojo;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">UserList</span> &#123;</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;User&gt; <span class="title function_">CreateList</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="comment">// 5万条数据插入1张表里，开20个线程并发插入</span></span><br><span class="line">        <span class="type">Integer</span> <span class="variable">max</span> <span class="operator">=</span>  <span class="number">2500</span>;</span><br><span class="line">        List&lt;User&gt; userList = <span class="keyword">new</span> <span class="title class_">ArrayList</span>(max);</span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i &lt; max; i++)&#123;</span><br><span class="line">            <span class="type">User</span> <span class="variable">u</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(i,<span class="string">&quot;汪伟&quot;</span>,<span class="string">&quot;天然5&quot;</span>,<span class="string">&quot;pwd&quot;</span>,<span class="number">8</span>,<span class="number">30</span>);</span><br><span class="line">            userList.add(u);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span>  userList;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;User&gt; <span class="title function_">CreateList200</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="comment">// 20万条数据，同时插入200张表里面，每张表插入1000条。 每张表开1个线程并发。</span></span><br><span class="line">        <span class="type">Integer</span> <span class="variable">max</span> <span class="operator">=</span>  <span class="number">1000</span>;</span><br><span class="line">        <span class="type">ArrayList</span> <span class="variable">userList</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ArrayList</span>(max);</span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span>; i &lt; max; i++)&#123;</span><br><span class="line">            <span class="type">User</span> <span class="variable">u</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">User</span>(i,<span class="string">&quot;汪伟&quot;</span>,<span class="string">&quot;天然5&quot;</span>,<span class="string">&quot;pwd&quot;</span>,<span class="number">8</span>,<span class="number">30</span>);</span><br><span class="line">            userList.add(u);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span>  userList;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="数据表和扩容"><a href="#数据表和扩容" class="headerlink" title="数据表和扩容"></a>数据表和扩容</h2><p>使用1.1.1.2和1.1.1.3上面的300版本的HDR集群来测试：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">工作目录</span></span><br><span class="line">cd /home/gbasedbt/200tab</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">表模板</span></span><br><span class="line">cat &gt; mb &lt;&lt; EOF</span><br><span class="line">CREATE TABLE t_user  (</span><br><span class="line">  id serial(8),</span><br><span class="line">  userName varchar(255),</span><br><span class="line">  realName varchar(255),</span><br><span class="line">  password varchar(255),</span><br><span class="line">  age int,</span><br><span class="line">  dId int,</span><br><span class="line">  PRIMARY KEY (id) </span><br><span class="line">);</span><br><span class="line">EOF</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">Mapper映射模板</span></span><br><span class="line">cat &gt; mbxml &lt;&lt; EOF</span><br><span class="line">    &lt;insert id=&quot;insertList&quot; &gt;</span><br><span class="line">        insert into t_user(userName,realName,password,age,dId) values (#&#123;userName&#125;,#&#123;realName&#125;,#&#123;password&#125;,#&#123;age&#125;,#&#123;dId&#125;)</span><br><span class="line">    &lt;/insert&gt;</span><br><span class="line">EOF</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">建表1张</span></span><br><span class="line">cp mb t_user.sql</span><br><span class="line">dbaccess testdb t_user.sql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">建表200张</span></span><br><span class="line">i=1</span><br><span class="line">while [ $i -le 200 ]</span><br><span class="line">do</span><br><span class="line">cat mb |sed &quot;s/t_user/t_user$&#123;i&#125;/&quot; &gt;&gt; 200tab.sql</span><br><span class="line">let i=$i+1</span><br><span class="line">done</span><br><span class="line">dbaccess testdb 200tab.sql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">清数200张</span></span><br><span class="line">i=1</span><br><span class="line">while [ $i -le 200 ]</span><br><span class="line">do</span><br><span class="line">echo &quot;truncate table t_user$&#123;i&#125;;&quot; &gt;&gt; 200truncat.sql</span><br><span class="line">let i=$i+1</span><br><span class="line">done</span><br><span class="line">dbaccess testdb 200truncat.sql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">mapper映射200个</span></span><br><span class="line">i=1</span><br><span class="line">while [ $i -le 200 ]</span><br><span class="line">do</span><br><span class="line">cat mbxml |sed &quot;s/t_user/t_user$&#123;i&#125;/&quot; |sed &quot;s/insertList/insert$&#123;i&#125;/&quot;&gt;&gt; 200tab.xml</span><br><span class="line">let i=$i+1</span><br><span class="line">done</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">扩容线程池</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">锁扩容</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">扩容NETTYPE</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">扩容CPU</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">扩容逻辑日志空间</span></span><br><span class="line">touch /data/g300/llogdbs </span><br><span class="line">chmod 660 /data/g300/llogdbs </span><br><span class="line">onspaces -a llogdbs -p /data/g300/llogdbs  -o 0 -s 1024000 </span><br><span class="line">onparams -a -d llogdbs -s 202800</span><br><span class="line">onparams -a -d llogdbs -s 202800</span><br><span class="line">onparams -a -d llogdbs -s 202800</span><br><span class="line">onparams -a -d llogdbs -s 202800</span><br><span class="line">onparams -a -d llogdbs -s 202800</span><br><span class="line">ontape -s -L 0 -t ~/0b</span><br><span class="line">scp ~/0b wei3:~/</span><br></pre></td></tr></table></figure>



<h2 id="Mapper映射"><a href="#Mapper映射" class="headerlink" title="Mapper映射"></a>Mapper映射</h2><p>D:\go\src\java\WeiMyBatis\src\main\java\com\trey\mybatis\pojo\UserMapper.xml</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span> ?&gt;</span></span><br><span class="line"><span class="meta">&lt;!DOCTYPE <span class="keyword">mapper</span></span></span><br><span class="line"><span class="meta">        <span class="keyword">PUBLIC</span> <span class="string">&quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;</span></span></span><br><span class="line"><span class="meta">        <span class="string">&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">mapper</span> <span class="attr">namespace</span>=<span class="string">&quot;com.trey.mybatis.pojo.User&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">select</span> <span class="attr">id</span>=<span class="string">&quot;query&quot;</span> <span class="attr">resultType</span>=<span class="string">&quot;com.trey.mybatis.pojo.User&quot;</span>&gt;</span></span><br><span class="line">        insert * from t_user;</span><br><span class="line">    <span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br><span class="line">    </span><br><span class="line">    <span class="tag">&lt;<span class="name">insert</span> <span class="attr">id</span>=<span class="string">&quot;insertList&quot;</span> &gt;</span></span><br><span class="line">        insert into t_user(userName,realName,password,age,dId) values (#&#123;userName&#125;,#&#123;realName&#125;,#&#123;password&#125;,#&#123;age&#125;,#&#123;dId&#125;)</span><br><span class="line">    <span class="tag">&lt;/<span class="name">insert</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">insert</span> <span class="attr">id</span>=<span class="string">&quot;insert1&quot;</span> &gt;</span></span><br><span class="line">        insert into t_user1(userName,realName,password,age,dId) values (#&#123;userName&#125;,#&#123;realName&#125;,#&#123;password&#125;,#&#123;age&#125;,#&#123;dId&#125;)</span><br><span class="line">    <span class="tag">&lt;/<span class="name">insert</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">insert</span> <span class="attr">id</span>=<span class="string">&quot;insert2&quot;</span> &gt;</span></span><br><span class="line">        insert into t_user2(userName,realName,password,age,dId) values (#&#123;userName&#125;,#&#123;realName&#125;,#&#123;password&#125;,#&#123;age&#125;,#&#123;dId&#125;)</span><br><span class="line">    <span class="tag">&lt;/<span class="name">insert</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">insert</span> <span class="attr">id</span>=<span class="string">&quot;insert3&quot;</span> &gt;</span></span><br><span class="line">        insert into t_user3(userName,realName,password,age,dId) values (#&#123;userName&#125;,#&#123;realName&#125;,#&#123;password&#125;,#&#123;age&#125;,#&#123;dId&#125;)</span><br><span class="line">    <span class="tag">&lt;/<span class="name">insert</span>&gt;</span></span><br><span class="line">   </span><br><span class="line"><span class="tag">&lt;/<span class="name">mapper</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h2 id="MyBatis核心配置文件"><a href="#MyBatis核心配置文件" class="headerlink" title="MyBatis核心配置文件"></a>MyBatis核心配置文件</h2><p>D:\go\src\java\WeiMyBatis\src\main\resources\mybatis-config.xml</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span> ?&gt;</span></span><br><span class="line"><span class="meta">&lt;!DOCTYPE <span class="keyword">configuration</span></span></span><br><span class="line"><span class="meta">        <span class="keyword">PUBLIC</span> <span class="string">&quot;-//mybatis.org//DTD Config 3.0//EN&quot;</span></span></span><br><span class="line"><span class="meta">        <span class="string">&quot;http://mybatis.org/dtd/mybatis-3-config.dtd&quot;</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">environments</span> <span class="attr">default</span>=<span class="string">&quot;development&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">environment</span> <span class="attr">id</span>=<span class="string">&quot;development&quot;</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">transactionManager</span> <span class="attr">type</span>=<span class="string">&quot;JDBC&quot;</span>/&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">dataSource</span> <span class="attr">type</span>=<span class="string">&quot;POOLED&quot;</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;poolMaximumActiveConnections&quot;</span> <span class="attr">value</span>=<span class="string">&quot;200&quot;</span>/&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;poolMaximumIdleConnections&quot;</span> <span class="attr">value</span>=<span class="string">&quot;20&quot;</span>/&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;driver&quot;</span> <span class="attr">value</span>=<span class="string">&quot;com.gbasedbt.jdbc.Driver&quot;</span>/&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;url&quot;</span> <span class="attr">value</span>=<span class="string">&quot;jdbc:gbasedbt-sqli:/testdb:GBASEDBTSERVER=cm_update;SQLH_TYPE=FILE;SQLH_FILE=D:\jdbc\sqlhosts.cm;SQLMODE=GBase;file=D:\jdbc\sqlhosts.cm;DB_LOCALE=zh_CN.57372;APPENDISAM=true;LOGINTIMEOUT=200;UPPER_CASE=y&quot;</span>/&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">value</span>=<span class="string">&quot;gbasedbt&quot;</span>/&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">property</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">value</span>=<span class="string">&quot;GBase123&quot;</span>/&gt;</span></span><br><span class="line"><span class="comment">&lt;!--                &lt;property name=&quot;driver&quot; value=&quot;com.mysql.cj.jdbc.Driver&quot;/&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--                &lt;property name=&quot;url&quot; value=&quot;jdbc:mysql://localhost:3306/mybatisdb?characterEncoding=utf-8&amp;amp;serverTimezone=UTC&quot;/&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--                &lt;property name=&quot;username&quot; value=&quot;root&quot;/&gt;--&gt;</span></span><br><span class="line"><span class="comment">&lt;!--                &lt;property name=&quot;password&quot; value=&quot;ww1984830&quot;/&gt;--&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">dataSource</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">environment</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">environments</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">mappers</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">mapper</span> <span class="attr">resource</span>=<span class="string">&quot;com/trey/mybatis/pojo/UserMapper.xml&quot;</span>/&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">mappers</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h2 id="单元测试代码"><a href="#单元测试代码" class="headerlink" title="单元测试代码"></a>单元测试代码</h2><p>D:\go\src\java\WeiMyBatis\src\test\java\com\trey\mybatis\test\Test01.java</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.trey.mybatis.test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.trey.mybatis.pojo.User;</span><br><span class="line"><span class="keyword">import</span> com.trey.mybatis.pojo.UserList;</span><br><span class="line"><span class="keyword">import</span> org.apache.ibatis.io.Resources;</span><br><span class="line"><span class="keyword">import</span> org.apache.ibatis.session.SqlSession;</span><br><span class="line"><span class="keyword">import</span> org.apache.ibatis.session.SqlSessionFactory;</span><br><span class="line"><span class="keyword">import</span> org.apache.ibatis.session.SqlSessionFactoryBuilder;</span><br><span class="line"><span class="keyword">import</span> org.junit.Test;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.io.IOException;</span><br><span class="line"><span class="keyword">import</span> java.io.InputStream;</span><br><span class="line"><span class="keyword">import</span> java.util.Date;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"><span class="keyword">import</span> java.util.concurrent.*;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Test01</span> &#123;</span><br><span class="line">    <span class="meta">@Test</span></span><br><span class="line">    <span class="keyword">public</span>  <span class="keyword">void</span>  <span class="title function_">test01</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="comment">//查询数据测试</span></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">// 读取全局配置文件</span></span><br><span class="line">            <span class="type">InputStream</span> <span class="variable">in</span> <span class="operator">=</span> Resources.getResourceAsStream(<span class="string">&quot;mybatis-config.xml&quot;</span>);</span><br><span class="line">            <span class="comment">// 获取SqlSessionFactory对象</span></span><br><span class="line">            <span class="type">SqlSessionFactory</span> <span class="variable">factory</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">SqlSessionFactoryBuilder</span>().build(in);</span><br><span class="line">            <span class="comment">// 获取SqlSession对象</span></span><br><span class="line">            <span class="type">SqlSession</span> <span class="variable">sqlSession</span> <span class="operator">=</span> factory.openSession();</span><br><span class="line">            <span class="comment">// 通过SqlSession执行数据库操作 : namespace+&quot;.&quot;+id</span></span><br><span class="line">            List&lt;User&gt; list = sqlSession.selectList(<span class="string">&quot;com.trey.mybatis.pojo.User.query&quot;</span>);</span><br><span class="line">            System.out.println(<span class="string">&quot;查询结果：.............................................................&quot;</span>);</span><br><span class="line">            <span class="keyword">for</span> (User user : list)&#123;</span><br><span class="line">                System.out.println(user);</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="comment">// 关闭会话</span></span><br><span class="line">            sqlSession.close();</span><br><span class="line">        &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//        //游标查询测试：Mysql可以跑，GBase不支持这么写。</span></span><br><span class="line"><span class="comment">//        try &#123;</span></span><br><span class="line"><span class="comment">//            // 读取全局配置文件</span></span><br><span class="line"><span class="comment">//            InputStream in = Resources.getResourceAsStream(&quot;mybatis-config.xml&quot;);</span></span><br><span class="line"><span class="comment">//            // 获取SqlSessionFactory对象</span></span><br><span class="line"><span class="comment">//            SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(in);</span></span><br><span class="line"><span class="comment">//            // 获取SqlSession对象</span></span><br><span class="line"><span class="comment">//            SqlSession sqlSession = factory.openSession();</span></span><br><span class="line"><span class="comment">//            // 通过SqlSession执行数据库操作 : namespace+&quot;.&quot;+id</span></span><br><span class="line"><span class="comment">//            Cursor&lt;User&gt; users = sqlSession.selectCursor(&quot;com.trey.mybatis.pojo.User.query&quot;);</span></span><br><span class="line"><span class="comment">//            Iterator&lt;User&gt; iterator = users.iterator();</span></span><br><span class="line"><span class="comment">//            //游标读取第1行</span></span><br><span class="line"><span class="comment">//            User next1 = iterator.next();</span></span><br><span class="line"><span class="comment">//            System.out.println(&quot;row 1:&quot;+next1);</span></span><br><span class="line"><span class="comment">//            //游标读取第2行</span></span><br><span class="line"><span class="comment">//            User next2 = iterator.next();</span></span><br><span class="line"><span class="comment">//            System.out.println(&quot;row 2:&quot;+next2);</span></span><br><span class="line"><span class="comment">//            // 关闭会话</span></span><br><span class="line"><span class="comment">//            sqlSession.close();</span></span><br><span class="line"><span class="comment">//        &#125; catch (IOException e) &#123;</span></span><br><span class="line"><span class="comment">//            e.printStackTrace();</span></span><br><span class="line"><span class="comment">//        &#125;</span></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Test</span></span><br><span class="line">    <span class="keyword">public</span>  <span class="keyword">void</span>  <span class="title function_">test02</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="type">UserList</span> <span class="variable">listClass</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">UserList</span>();</span><br><span class="line">        List&lt;User&gt; list = listClass.CreateList();</span><br><span class="line">        <span class="comment">//批量插入测试：5万条数据插入1张表里，开20个线程并发插入</span></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">// 读取全局配置文件</span></span><br><span class="line">            <span class="type">InputStream</span> <span class="variable">in</span> <span class="operator">=</span> Resources.getResourceAsStream(<span class="string">&quot;mybatis-config.xml&quot;</span>);</span><br><span class="line">            <span class="comment">// 获取SqlSessionFactory对象</span></span><br><span class="line">            <span class="type">SqlSessionFactory</span> <span class="variable">factory</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">SqlSessionFactoryBuilder</span>().build(in);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 创建一个线程池</span></span><br><span class="line">            <span class="type">ExecutorService</span> <span class="variable">threadPool</span> <span class="operator">=</span> Executors.newCachedThreadPool();</span><br><span class="line">            <span class="comment">// 20个并发insert</span></span><br><span class="line">            <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span> ; i&lt;<span class="number">20</span>; i++)&#123;</span><br><span class="line">                threadPool.execute(()-&gt;&#123;</span><br><span class="line">                    <span class="comment">// 获取SqlSession对象</span></span><br><span class="line">                    <span class="type">SqlSession</span> <span class="variable">sqlSession</span> <span class="operator">=</span> factory.openSession();</span><br><span class="line">                    <span class="comment">// 通过SqlSession执行数据库操作 : namespace+&quot;.&quot;+id</span></span><br><span class="line">                    <span class="type">Date</span> <span class="variable">nowTime1</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line">                    System.out.println(nowTime1);</span><br><span class="line">                    <span class="keyword">for</span> (User u : list ) &#123;</span><br><span class="line">                        sqlSession.insert(<span class="string">&quot;com.trey.mybatis.pojo.User.insertList&quot;</span>,u);</span><br><span class="line">                    &#125;</span><br><span class="line">                    sqlSession.commit();</span><br><span class="line">                    <span class="type">Date</span> <span class="variable">nowTime2</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line">                    System.out.println(nowTime2);</span><br><span class="line">                    <span class="comment">//计算一下时间差</span></span><br><span class="line">                    <span class="type">double</span> <span class="variable">millisecond</span> <span class="operator">=</span> nowTime2.getTime() - nowTime1.getTime();</span><br><span class="line">                    System.out.println(millisecond/<span class="number">1000</span>);</span><br><span class="line">                    <span class="comment">// 关闭会话</span></span><br><span class="line">                    sqlSession.close();</span><br><span class="line">                &#125;);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                TimeUnit.SECONDS.sleep(<span class="number">60</span>);</span><br><span class="line">            &#125; <span class="keyword">catch</span> (InterruptedException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Test</span></span><br><span class="line">    <span class="keyword">public</span>  <span class="keyword">void</span>  <span class="title function_">test03</span><span class="params">()</span>&#123;</span><br><span class="line">        <span class="type">UserList</span> <span class="variable">listClass</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">UserList</span>();</span><br><span class="line">        List&lt;User&gt; list = listClass.CreateList200();</span><br><span class="line">        <span class="comment">//批量插入测试：20万条数据，同时插入200张表里面，每张表插入1000条。 每张表开1个线程并发,共200个并发。</span></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="comment">// 读取全局配置文件</span></span><br><span class="line">            <span class="type">InputStream</span> <span class="variable">in</span> <span class="operator">=</span> Resources.getResourceAsStream(<span class="string">&quot;mybatis-config.xml&quot;</span>);</span><br><span class="line">            <span class="comment">// 获取SqlSessionFactory对象</span></span><br><span class="line">            <span class="type">SqlSessionFactory</span> <span class="variable">factory</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">SqlSessionFactoryBuilder</span>().build(in);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">            <span class="comment">// 创建一个线程池</span></span><br><span class="line"><span class="comment">//            ExecutorService threadPool = Executors.newCachedThreadPool();</span></span><br><span class="line">            <span class="type">ThreadPoolExecutor</span> <span class="variable">threadPool</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>(<span class="number">200</span>,<span class="number">300</span>,<span class="number">60</span>,TimeUnit.SECONDS,<span class="keyword">new</span> <span class="title class_">ArrayBlockingQueue</span>&lt;&gt;(<span class="number">3</span>),Executors.defaultThreadFactory(),<span class="keyword">new</span> <span class="title class_">ThreadPoolExecutor</span>.AbortPolicy());</span><br><span class="line">            <span class="comment">// 10个并发insert</span></span><br><span class="line">            <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">1</span> ; i&lt;<span class="number">201</span>; i++)&#123;</span><br><span class="line">                <span class="keyword">final</span>  <span class="type">int</span> <span class="variable">n</span> <span class="operator">=</span> i;</span><br><span class="line">                threadPool.execute(()-&gt;&#123;</span><br><span class="line">                    <span class="comment">// 获取SqlSession对象</span></span><br><span class="line">                    <span class="type">SqlSession</span> <span class="variable">sqlSession</span> <span class="operator">=</span> factory.openSession();</span><br><span class="line">                    <span class="comment">// 通过SqlSession执行数据库操作 : namespace+&quot;.&quot;+id</span></span><br><span class="line">                    <span class="type">Date</span> <span class="variable">nowTime1</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line">                    System.out.println(nowTime1);</span><br><span class="line">                    <span class="type">String</span> <span class="variable">s</span> <span class="operator">=</span> <span class="string">&quot;com.trey.mybatis.pojo.User.insert&quot;</span>+n;</span><br><span class="line">                    <span class="keyword">for</span> (User u : list ) &#123;</span><br><span class="line">                        sqlSession.insert(s,u);</span><br><span class="line">                    &#125;</span><br><span class="line">                    sqlSession.commit();</span><br><span class="line">                    <span class="type">Date</span> <span class="variable">nowTime2</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line">                    System.out.println(nowTime2);</span><br><span class="line">                    <span class="comment">//计算一下时间差</span></span><br><span class="line">                    <span class="type">double</span> <span class="variable">millisecond</span> <span class="operator">=</span> nowTime2.getTime() - nowTime1.getTime();</span><br><span class="line">                    System.out.println(millisecond/<span class="number">1000</span>);</span><br><span class="line">                    <span class="comment">// 关闭会话</span></span><br><span class="line">                    sqlSession.close();</span><br><span class="line">                &#125;);</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                TimeUnit.SECONDS.sleep(<span class="number">120</span>);</span><br><span class="line">            &#125; <span class="keyword">catch</span> (InterruptedException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (IOException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="Manve项目依赖"><a href="#Manve项目依赖" class="headerlink" title="Manve项目依赖"></a>Manve项目依赖</h2><p>D:\go\src\java\WeiMyBatis\pom.xml</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span>?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">project</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://maven.apache.org/POM/4.0.0&quot;</span></span></span><br><span class="line"><span class="tag">         <span class="attr">xmlns:xsi</span>=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span></span><br><span class="line"><span class="tag">         <span class="attr">xsi:schemaLocation</span>=<span class="string">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">modelVersion</span>&gt;</span>4.0.0<span class="tag">&lt;/<span class="name">modelVersion</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.example<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>WeiMyBatis<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.mybatis<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mybatis<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.5.11<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>mysql<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mysql-connector-java<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>8.0.30<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.projectlombok<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>lombok<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.18.24<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>junit<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>junit<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>4.13.2<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">scope</span>&gt;</span>test<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>junit<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>junit<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>4.13.2<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">scope</span>&gt;</span>test<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">resources</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">resource</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">directory</span>&gt;</span></span><br><span class="line">                    src/main/java</span><br><span class="line">                <span class="tag">&lt;/<span class="name">directory</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">includes</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">include</span>&gt;</span></span><br><span class="line">                        **/*.xml</span><br><span class="line">                    <span class="tag">&lt;/<span class="name">include</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">includes</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">resource</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">resources</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">maven.compiler.source</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.source</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">maven.compiler.target</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.target</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">project</span>&gt;</span></span><br></pre></td></tr></table></figure>





<h2 id="运行单元测试，错误处理"><a href="#运行单元测试，错误处理" class="headerlink" title="运行单元测试，错误处理"></a>运行单元测试，错误处理</h2><h5 id="Could-not-find-resource-mybatis-config-xml"><a href="#Could-not-find-resource-mybatis-config-xml" class="headerlink" title="Could not find resource mybatis-config.xml"></a>Could not find resource mybatis-config.xml</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">处理： 直接把mybatis-config.xml文件复制到target/classs目录下即可。</span><br></pre></td></tr></table></figure>

<h5 id="Cannot-find-class-com-gbasedbt-jdbc-Driver-The-error"><a href="#Cannot-find-class-com-gbasedbt-jdbc-Driver-The-error" class="headerlink" title="Cannot find class: com.gbasedbt.jdbc.Driver The error"></a>Cannot find class: com.gbasedbt.jdbc.Driver The error</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">处理： </span><br><span class="line">1、 文件--》项目结构--》模块--》依赖--驱动之前的gbase驱动。</span><br><span class="line">2、 文件--》项目结构--》库--》添加信的gbase驱动。</span><br></pre></td></tr></table></figure>

<h5 id="Cause-java-sql-SQLException-A-syntax-error-has-occurred"><a href="#Cause-java-sql-SQLException-A-syntax-error-has-occurred" class="headerlink" title="Cause: java.sql.SQLException: A syntax error has occurred"></a>Cause: java.sql.SQLException: A syntax error has occurred</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">org.apache.ibatis.exceptions.PersistenceException: </span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">## Error querying database.  Cause: java.sql.SQLException: A syntax error has occurred.</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">## The error may exist in com/trey/mybatis/pojo/UserMapper.xml</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">## The error may involve com.trey.mybatis.pojo.User.query</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">## The error occurred while executing a query</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">## SQL: insert * from t_user;</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">## Cause: java.sql.SQLException: A syntax error has occurred.</span></span></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">处理： 把下面的insert改成<span class="keyword">select</span></span></span><br><span class="line">&lt;mapper namespace=&quot;com.trey.mybatis.pojo.User&quot;&gt;</span><br><span class="line">    &lt;select id=&quot;query&quot; resultType=&quot;com.trey.mybatis.pojo.User&quot;&gt;</span><br><span class="line">        insert * from t_user;</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/mybatis/" rel="tag">mybatis</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B/" rel="tag">测试用例</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8sDruid测试用例"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8sDruid%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B/"
    >GBase8sDruid测试用例</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8sDruid%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B/" class="article-date">
  <time datetime="2023-05-10T01:32:16.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="软件下载"><a href="#软件下载" class="headerlink" title="软件下载"></a>软件下载</h2><ul>
<li><p>德鲁伊druid-1.2.9.jar</p>
<ul>
<li><p>德鲁伊官网： <a target="_blank" rel="noopener" href="https://github.com/alibaba/druid">https://github.com/alibaba/druid</a> </p>
</li>
<li><p>德鲁伊中文文档：<a target="_blank" rel="noopener" href="https://github.com/alibaba/druid/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98">https://github.com/alibaba/druid/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98</a></p>
</li>
<li><p>下载druid的地址：</p>
<p><a target="_blank" rel="noopener" href="http://repo1.maven.org/maven2/com/alibaba/druid/druid-wrapper/%E4%B8%8B%E8%BD%BDdruid-wrapper-xxx.jar">http://repo1.maven.org/maven2/com/alibaba/druid/druid-wrapper/下载druid-wrapper-xxx.jar</a>  </p>
<p><a target="_blank" rel="noopener" href="https://repo1.maven.org/maven2/com/alibaba/druid/1.2.9/druid-1.2.9.jar">https://repo1.maven.org/maven2/com/alibaba/druid/1.2.9/druid-1.2.9.jar</a></p>
</li>
</ul>
</li>
<li><p>开发环境</p>
<ul>
<li>IntelliJ IDEA 2021.2.3</li>
<li>参考<a target="_blank" rel="noopener" href="http://www.wangwei.com:8080/blog/10">http://www.wangwei.com:8080/blog/10</a></li>
</ul>
</li>
<li><p>数据库和驱动</p>
<ul>
<li><p>GBase8s 330</p>
</li>
<li><p>gbasedbtjdbc_3.3.0_2_36477d.jar</p>
</li>
</ul>
</li>
</ul>
<h2 id="新建Web项目"><a href="#新建Web项目" class="headerlink" title="新建Web项目"></a>新建Web项目</h2><pre><code>1. 文件-》新建-》新模块
2. Java Enterprise-》名称WeiDruid，位置D:\soft\src\Java\WeiDruid，项目模板Web，应用服务器Tomcat8.5.78
3. src-》main -》webapp-》WEB-INF -》新建 -》目录：lib
4. 把gbasedbtjdbc_3.3.0_2_36477d.jar和druid-1.2.9.jar
5. 文件-》项目结构-》模块-》依赖-》加号导入上面两个jar包
</code></pre>
<h2 id="启动Web项目测试一下"><a href="#启动Web项目测试一下" class="headerlink" title="启动Web项目测试一下"></a>启动Web项目测试一下</h2><p>​	验证一下首页释放能访问：<a target="_blank" rel="noopener" href="http://localhost:8080/WeiDruid_war_exploded/">http://localhost:8080/WeiDruid_war_exploded/</a></p>
<p>​	如果报错： 运行 ‘Tomcat 8.5.78’ 时出错: Can’t find catalina.jar	</p>
<p>​	报错处理： 重新解压安装Tomcat。</p>
<h2 id="写一个最简单的单元测试"><a href="#写一个最简单的单元测试" class="headerlink" title="写一个最简单的单元测试"></a>写一个最简单的单元测试</h2><p>​	在test目录下新建类：com.trey.druid.test.Test02</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.trey.druid.test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> org.junit.jupiter.api.Test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Test02</span> &#123;</span><br><span class="line">    <span class="meta">@Test</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">func01</span><span class="params">()</span> &#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;你好,不多和尚.&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>​	然后，点击运行func01，即可显示”你好,不多和尚.”。</p>
<h2 id="Druid连接池测试"><a href="#Druid连接池测试" class="headerlink" title="Druid连接池测试"></a>Druid连接池测试</h2><h3 id="创建连接池-200个连接"><a href="#创建连接池-200个连接" class="headerlink" title="创建连接池-200个连接"></a>创建连接池-200个连接</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.trey.druid.test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.alibaba.druid.pool.DruidDataSource;</span><br><span class="line"><span class="keyword">import</span> com.alibaba.druid.pool.DruidPooledConnection;</span><br><span class="line"><span class="keyword">import</span> org.junit.jupiter.api.Test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.sql.SQLException;</span><br><span class="line"><span class="keyword">import</span> java.util.Date;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Test02</span> &#123;</span><br><span class="line">    <span class="meta">@Test</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">func01</span><span class="params">()</span> &#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;你好,不多和尚.&quot;</span>);</span><br><span class="line">        <span class="type">DruidDataSource</span> <span class="variable">dataSource</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">DruidDataSource</span>();</span><br><span class="line">        dataSource.setDriverClassName(<span class="string">&quot;com.gbasedbt.jdbc.Driver&quot;</span>);</span><br><span class="line">        dataSource.setUrl(<span class="string">&quot;jdbc:gbasedbt-sqli:/testdb:GBASEDBTSERVER=db_group;SQLH_TYPE=FILE;SQLH_FILE=D:\\soft\\jdbc\\sqlhosts.shuangzhu.txt;SQLMODE=GBase;file=D:\\soft\\jdbc\\sqlhosts.text.txt;DB_LOCALE=zh_CN.57372;CLIENT_LOCALE=zh_CN.utf8;LOGINTIMEOUT=200;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y&quot;</span>);</span><br><span class="line">        dataSource.setUsername(<span class="string">&quot;gbasedbt&quot;</span>);</span><br><span class="line">        dataSource.setPassword(<span class="string">&quot;GBase123&quot;</span>);</span><br><span class="line">        dataSource.setMaxActive(<span class="number">300</span>);</span><br><span class="line"></span><br><span class="line">        <span class="type">Date</span> <span class="variable">date</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line"></span><br><span class="line">        <span class="keyword">for</span> (<span class="type">int</span> <span class="variable">i</span> <span class="operator">=</span> <span class="number">0</span> ; i&lt;<span class="number">200</span>; i++) &#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                <span class="type">DruidPooledConnection</span> <span class="variable">connection</span> <span class="operator">=</span> dataSource.getConnection();</span><br><span class="line">                date = <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line">                System.out.println(date.toString() + <span class="string">&quot; : 取得了1个连接： &quot;</span>+connection);</span><br><span class="line">            &#125; <span class="keyword">catch</span> (SQLException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">                date = <span class="keyword">new</span> <span class="title class_">Date</span>();</span><br><span class="line">                System.out.println(date.toString() + <span class="string">&quot; : 建立连接失败了&quot;</span>);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Thread.sleep(<span class="number">60000</span>);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (InterruptedException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>





<h2 id="报错处理"><a href="#报错处理" class="headerlink" title="报错处理"></a>报错处理</h2><h4 id="下面这个报错，的原因是sqlhosts-tesxt-txt文件不存在："><a href="#下面这个报错，的原因是sqlhosts-tesxt-txt文件不存在：" class="headerlink" title="下面这个报错，的原因是sqlhosts.tesxt.txt文件不存在："></a>下面这个报错，的原因是sqlhosts.tesxt.txt文件不存在：</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">十二月 02, 2022 4:26:02 下午 com.alibaba.druid.pool.DruidDataSource error</span><br><span class="line">严重: create connection SQLException, url: jdbc:gbasedbt-sqli:/testdb:GBASEDBTSERVER=db_group;SQLH_TYPE=FILE;SQLH_FILE=D:\soft\jdbc\sqlhosts.tesxt.txt;SQLMODE=GBase;file=D:\soft\jdbc\sqlhosts.text.txt;DB_LOCALE=zh_CN.57372;CLIENT_LOCALE=zh_CN.utf8;LOGINTIMEOUT=200;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y, errorCode -25563, state IX000</span><br><span class="line">java.sql.SQLException: com.gbasedbt.asf.IfxASFException: Invalid ASF API input parameters.</span><br><span class="line">	at com.gbasedbt.jdbc.IfxSqliConnect.&lt;init&gt;(IfxSqliConnect.java:1611)</span><br><span class="line">	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)</span><br><span class="line">	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)</span><br><span class="line">	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)</span><br><span class="line">	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)</span><br><span class="line">	at com.gbasedbt.jdbc.Driver.connect(Driver.java:252)</span><br><span class="line">	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1667)</span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/druid/" rel="tag">druid</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/jdbc/" rel="tag">jdbc</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%B5%8B%E8%AF%95%E7%94%A8%E4%BE%8B/" rel="tag">测试用例</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%BF%9E%E6%8E%A5%E6%B1%A0/" rel="tag">连接池</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8sjdbc连接串相关"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8sjdbc%E8%BF%9E%E6%8E%A5%E4%B8%B2%E7%9B%B8%E5%85%B3/"
    >GBase8sjdbc连接串相关</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8sjdbc%E8%BF%9E%E6%8E%A5%E4%B8%B2%E7%9B%B8%E5%85%B3/" class="article-date">
  <time datetime="2023-05-10T01:31:15.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h5 id="HDR环境，通过SQLH-FILE连接db-group"><a href="#HDR环境，通过SQLH-FILE连接db-group" class="headerlink" title="HDR环境，通过SQLH_FILE连接db_group"></a>HDR环境，通过SQLH_FILE连接db_group</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">db_group        group   -       -       i=1</span><br><span class="line">g300     onsoctcp 1.1.1.2 9082 g=db_group</span><br><span class="line">g300_hdr onsoctcp 1.1.1.3 9082 g=db_group</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jdbc:gbasedbt-sqli:/testdb:GBASEDBTSERVER=db_group;SQLH_TYPE=FILE;SQLH_FILE=D:\soft\jdbc\sqlhosts.text.txt;SQLMODE=GBase;file=D:\soft\jdbc\sqlhosts.text.txt;DB_LOCALE=zh_CN.57372;CLIENT_LOCALE=zh_CN.utf8;LOGINTIMEOUT=200;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y</span><br></pre></td></tr></table></figure>

<ul>
<li><h6 id="测试结果：（测试环境注明：ServerBuildNumber-3-0-0-93e040，-DRAUTO-x3D-0-，-JdbcDriver：3-3-0-2-）"><a href="#测试结果：（测试环境注明：ServerBuildNumber-3-0-0-93e040，-DRAUTO-x3D-0-，-JdbcDriver：3-3-0-2-）" class="headerlink" title="测试结果：（测试环境注明：ServerBuildNumber: 3.0.0_93e040， DRAUTO&#x3D;0 ， JdbcDriver：3.3.0_2 ）"></a>测试结果：（测试环境注明：ServerBuildNumber: 3.0.0_93e040， DRAUTO&#x3D;0 ， JdbcDriver：3.3.0_2 ）</h6></li>
</ul>
<ol>
<li><p>APP只会连接到组中的主节点，不会连接到备节点。</p>
</li>
<li><p>如果主节点宕机了，APP就会报错并且连接不上备节点。</p>
</li>
<li><p>如果主节点宕机了，备节点人为调整为standard模式，APP可以连接上来。</p>
</li>
<li><p>如果主节点宕机了，备节点人为调整为standard模式，此时再启动主节点数据库会收到报错，并不会出现双主。此时只要要PHY启动并加会集群即可。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">应用程序端收到的报错：</span></span><br><span class="line">Product: DbVisualizer Pro 10.0.20 [Build #2901]</span><br><span class="line">OS: Windows 10</span><br><span class="line">OS Version: 10.0</span><br><span class="line">OS Arch: amd64</span><br><span class="line">Java Version: 1.8.0_202</span><br><span class="line">Java VM: Java HotSpot(TM) 64-Bit Server VM</span><br><span class="line">Java Vendor: Oracle Corporation</span><br><span class="line">Java Home: d:\install\dbvisualizer\jre</span><br><span class="line">DbVis Home: D:\install\DbVisualizer</span><br><span class="line">User Home: C:\Users\Lenovo</span><br><span class="line">PrefsDir: C:\Users\Lenovo\.dbvis</span><br><span class="line">SessionId: 162</span><br><span class="line">BindDir: C:\Users\Lenovo\.dbvis\[0]</span><br><span class="line"></span><br><span class="line">An error occurred while establishing the connection:</span><br><span class="line"></span><br><span class="line">Long Message:</span><br><span class="line">None of the server in group is in primary or standard mode.</span><br><span class="line"></span><br><span class="line">Details:</span><br><span class="line">???Type: java.sql.SQLException</span><br><span class="line">???Error Code: -27009</span><br><span class="line">???SQL State: IX000</span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
</ol>
<p><strong>小结：通过SQLH_FILE连接db_group，程序只会连接到组中的主节点或标准节点，不会连接到备节点。</strong></p>
<h5 id="HDR环境，通过ENABLE-HDRSWITCH连接HDR集群"><a href="#HDR环境，通过ENABLE-HDRSWITCH连接HDR集群" class="headerlink" title="HDR环境，通过ENABLE_HDRSWITCH连接HDR集群"></a>HDR环境，通过ENABLE_HDRSWITCH连接HDR集群</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">db_group        group   -       -       i=1</span><br><span class="line">g300     onsoctcp 1.1.1.2 9082 g=db_group</span><br><span class="line">g300_hdr onsoctcp 1.1.1.3 9082 g=db_group</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jdbc:gbasedbt-sqli://1.1.1.2:9082/testdb:GBASEDBTSERVER=g300;ENABLE_HDRSWITCH=true;IFXHOST=1.1.1.2;PORTNO=9082;GBASEDBTSERVER_SECONDARY=g300_hdr;IFXHOST_SECONDARY=1.1.1.3;PORTNO_SECONDARY=9082;DB_LOCALE=zh_CN.utf8;CLIENT_LOCALE=zh_CN.utf8;LOGINTIMEOUT=200;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y</span><br></pre></td></tr></table></figure>

<ul>
<li><h6 id="测试结果：（测试环境注明：ServerBuildNumber-3-0-0-93e040，-DRAUTO-x3D-0-，-JdbcDriver：3-3-0-2-）-1"><a href="#测试结果：（测试环境注明：ServerBuildNumber-3-0-0-93e040，-DRAUTO-x3D-0-，-JdbcDriver：3-3-0-2-）-1" class="headerlink" title="测试结果：（测试环境注明：ServerBuildNumber: 3.0.0_93e040， DRAUTO&#x3D;0 ， JdbcDriver：3.3.0_2 ）"></a>测试结果：（测试环境注明：ServerBuildNumber: 3.0.0_93e040， DRAUTO&#x3D;0 ， JdbcDriver：3.3.0_2 ）</h6></li>
</ul>
<ol>
<li>使用上述 URL 连接 HDR 服务器对，当参数 GBASEDBTSERVER指定的主服务器正常运行时，应用程序被连接到服务器上，当主服务器发生错误时，应用程序会连接到 GBASEDBTSERVER_SECONDARY指定的务器上。</li>
<li>这种写法不会真的考虑谁是主谁是备。</li>
<li>这种写法只是给APP提供了两个连接地址，APP先找GBASEDBTSERVER，如果不通再找GBASEDBTSERVER_SECONDARY。</li>
<li>这种写法需要配合DRAUTO&#x3D;1使用，即：保留GBASEDBTSERVER指定的节点为主节点。</li>
</ol>
<p><strong>小结：ENABLE_HDRSWITCH连接HDR集群，程序会顺序连接。</strong></p>
<h5 id="扩展：普通的单点连接字符串："><a href="#扩展：普通的单点连接字符串：" class="headerlink" title="扩展：普通的单点连接字符串："></a>扩展：普通的单点连接字符串：</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">jdbc:gbasedbt-sqli://1.1.1.2:9082/testdb:GBASEDBTSERVER=g300;CLIENT_LOCALE=zh_cn.utf8;DB_LOCALE=zh_cn.utf8;LOGINTIMEOUT=200;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y;DBDATE=Y4MD</span><br></pre></td></tr></table></figure>



<h5 id="扩展结论1：DRAOUTO参数设置为0-的时候如果主备之间的网络没有断开，并不会出现双主，后启动的主节点会自动宕机。"><a href="#扩展结论1：DRAOUTO参数设置为0-的时候如果主备之间的网络没有断开，并不会出现双主，后启动的主节点会自动宕机。" class="headerlink" title="扩展结论1：DRAOUTO参数设置为0 的时候如果主备之间的网络没有断开，并不会出现双主，后启动的主节点会自动宕机。"></a>扩展结论1：DRAOUTO参数设置为0 的时候如果主备之间的网络没有断开，并不会出现双主，后启动的主节点会自动宕机。</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">数据库端收到的报错：</span></span><br><span class="line">[gbasedbt@wei3 ~]$ onstat -m</span><br><span class="line">shared memory not initialized for GBASEDBTSERVER &#x27;g300_hdr&#x27;</span><br><span class="line"></span><br><span class="line">Message Log File: /opt/install/g300/tmp/online.log</span><br><span class="line">16:26:26  Started 1 B-tree scanners.</span><br><span class="line">16:26:26  B-tree scanner threshold set at 5000.</span><br><span class="line">16:26:26  B-tree scanner range scan size set to -1.</span><br><span class="line">16:26:26  B-tree scanner ALICE mode set to 6.</span><br><span class="line">16:26:26  B-tree scanner index compression level set to med.</span><br><span class="line">16:26:26  DR: Reservation of the last logical log for log backup turned on</span><br><span class="line">16:26:26  DR: Trying to connect to secondary server = g300</span><br><span class="line">16:26:27  DR: Turned off on primary server</span><br><span class="line">16:26:27  DR: Local and Remote server type and/or last change(LC) incompatible</span><br><span class="line">              [Local  type: Primary,    LC: Primary mode]</span><br><span class="line">              [Remote type: Standard,   LC: ]</span><br><span class="line"></span><br><span class="line">16:26:27  DR: Cannot start the Primary server when the paired server is of</span><br><span class="line">              incompatible (Primary or Standard) type. Please convert</span><br><span class="line">              the paired server to compatible (Secondary) type.</span><br><span class="line">16:26:27  oninit: Fatal error in shared memory initialization</span><br><span class="line"></span><br><span class="line">16:26:27  GBase Database Server Stopped.</span><br><span class="line"></span><br><span class="line">16:26:27  mt_shm_remove: WARNING: may not have removed all/correct segments</span><br><span class="line">[gbasedbt@wei3 ~]$ </span><br></pre></td></tr></table></figure>

<h5 id="扩展结论2：DRAOUTO参数设置为1-x2F-2的时候，如果主备都宕机了，此时单独先启动备，备起来后还是备并不会出现多主。"><a href="#扩展结论2：DRAOUTO参数设置为1-x2F-2的时候，如果主备都宕机了，此时单独先启动备，备起来后还是备并不会出现多主。" class="headerlink" title="扩展结论2：DRAOUTO参数设置为1&#x2F;2的时候，如果主备都宕机了，此时单独先启动备，备起来后还是备并不会出现多主。"></a>扩展结论2：DRAOUTO参数设置为1&#x2F;2的时候，如果主备都宕机了，此时单独先启动备，备起来后还是备并不会出现多主。</h5><h5 id="扩展结论3：DRAOUTO参数设置为1-x2F-2的时候，如果主备都宕机了，此时同时启动主和备，起来后角色不会变，只是HDR状态是off，需要再次onmode-secondary一下。"><a href="#扩展结论3：DRAOUTO参数设置为1-x2F-2的时候，如果主备都宕机了，此时同时启动主和备，起来后角色不会变，只是HDR状态是off，需要再次onmode-secondary一下。" class="headerlink" title="扩展结论3：DRAOUTO参数设置为1&#x2F;2的时候，如果主备都宕机了，此时同时启动主和备，起来后角色不会变，只是HDR状态是off，需要再次onmode-secondary一下。"></a>扩展结论3：DRAOUTO参数设置为1&#x2F;2的时候，如果主备都宕机了，此时同时启动主和备，起来后角色不会变，只是HDR状态是off，需要再次onmode-secondary一下。</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">nohup oninit -vy &amp;</span><br><span class="line">ssh wei3 &quot;. /home/gbasedbt/.bash_profile; oninit -vy &amp;&quot;</span><br><span class="line">sleep 60;</span><br><span class="line">onmode -d secondary g300_hdr</span><br></pre></td></tr></table></figure>



<h5 id="扩展推论1：关于双主的出现"><a href="#扩展推论1：关于双主的出现" class="headerlink" title="扩展推论1：关于双主的出现"></a>扩展推论1：关于双主的出现</h5><ul>
<li>出现双主的主要原因是主备之间的网络不通。</li>
<li>如果网络是通的，DRAUTO参数为1&#x2F;2的情况下不会出现双主，除非人工干预改变了一些值。</li>
<li>DRAUTO参数为0的情况下，就是纯人工维护集群关系，人不犯傻就不会出现双主。</li>
</ul>
<h5 id="扩展推论2：关于双主的预防"><a href="#扩展推论2：关于双主的预防" class="headerlink" title="扩展推论2：关于双主的预防"></a>扩展推论2：关于双主的预防</h5><ul>
<li>如果主备之间的网络断开了，就会出现双主。</li>
<li>如果主备之间是同一个网关，那么主备之间的网络不通，就是主到网关不通或者备到网关不通，此时我们只要是检测到谁到网关不通就自杀，就不会出现双主问题。（此时不用考虑网关故障，如果网关故障我们把两个数据库都关闭了也正常）。</li>
</ul>
<h5 id="扩展推论2：万一出现双主的处理"><a href="#扩展推论2：万一出现双主的处理" class="headerlink" title="扩展推论2：万一出现双主的处理"></a>扩展推论2：万一出现双主的处理</h5><ul>
<li>如果已经双主了，那么通过SQLH_FILE连接db_group的连接方式会连接到组里面的多个实例。group好像可以控制先连接第一个实例，连接不上再连接第二个实例。</li>
<li>如果已经双主了，通过ENABLE_HDRSWITCH连接HDR集群的连接方法会优先连接GBASEDBTSERVER。</li>
<li>如果已经双主了，就会有数据写错地方的风险。</li>
</ul>
<h5 id="扩展推论3：需要两个程序"><a href="#扩展推论3：需要两个程序" class="headerlink" title="扩展推论3：需要两个程序"></a>扩展推论3：需要两个程序</h5><ul>
<li><p>其一，ping不通网关自杀。</p>
</li>
<li><p>其二，检测当前是不是双主，如果是，杀掉日志较少的实例。</p>
</li>
</ul>
<h5 id="扩展推论4：回过头来想想想双主这个事"><a href="#扩展推论4：回过头来想想想双主这个事" class="headerlink" title="扩展推论4：回过头来想想想双主这个事"></a>扩展推论4：回过头来想想想双主这个事</h5><ul>
<li><p>双主的出现只会是这两个原因导致的：主备间的网络断开  或   人工犯傻</p>
</li>
<li><p>人工犯傻我们不考虑。</p>
</li>
<li><p>主备间的网络断开，如果集群配置和APP应用，用的是通一个服务名，那么就是说主备断开的时候必然有一个节点的APP连接网络也是断开的，也就是说这个节点这时候是接收不到APP数据的。那么此时即使双主，也不会有数据写入到这个节点，此时我们只要把这个端口不通的实例关闭掉数据就安全了。等网络恢复后再把这个关闭的实例也备机的身份加入集群即可。</p>
</li>
</ul>
<h3 id="后来测试发现"><a href="#后来测试发现" class="headerlink" title="后来测试发现"></a>后来测试发现</h3><h6 id="发现：-主备间的网络断开了，备机自动会变成主，当主备的网络恢复后，主机再找到备机的时候，主会自杀以保护集群数据安全。"><a href="#发现：-主备间的网络断开了，备机自动会变成主，当主备的网络恢复后，主机再找到备机的时候，主会自杀以保护集群数据安全。" class="headerlink" title="发现： 主备间的网络断开了，备机自动会变成主，当主备的网络恢复后，主机再找到备机的时候，主会自杀以保护集群数据安全。"></a>发现： 主备间的网络断开了，备机自动会变成主，当主备的网络恢复后，主机再找到备机的时候，主会自杀以保护集群数据安全。</h6><p><strong>当时的原主机日志如下：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">14:56:13  Checkpoint Completed:  duration was 26 seconds.</span><br><span class="line">14:56:13  Fri Dec  2 - loguniq 9, logpos 0x8295018, timestamp: 0x1463a3 Interval: 328</span><br><span class="line"></span><br><span class="line">14:56:13  Maximum server connections 200</span><br><span class="line">14:56:13  Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 4, Llog used 2</span><br><span class="line"></span><br><span class="line">14:59:01  DR: Receive error</span><br><span class="line">14:59:02  dr_prsend thread : asfcode = -25582: oserr = 0: errstr = : Network connection is broken.</span><br><span class="line"></span><br><span class="line">14:59:02  DR_ERR set to -1</span><br><span class="line">14:59:02  SMX thread is exiting</span><br><span class="line">14:59:04  DR: Turned off on primary server</span><br><span class="line">14:59:04  DR: Cannot connect to secondary server</span><br><span class="line">14:59:04  Process exited with return code 126: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 15 &quot;Data Replication failure.&quot; &quot;DR: Turned off on </span><br><span class="line">primary server&quot; &quot;&quot; 15002</span><br><span class="line">14:59:04  Process exited with return code 126: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 15 &quot;Data Replication failure.&quot; &quot;DR: Cannot connect to secondary server&quot; &quot;&quot; 15003</span><br><span class="line">14:59:17  DR: Primary server detected peer is now primary or standard.</span><br><span class="line">              Use oninit to restart this server as HDR secondary.</span><br><span class="line">14:59:17  DR:Shutting down the server.</span><br><span class="line">14:59:17  DR:Terminating the master daemon to bring system down immediately.</span><br><span class="line">14:59:19  The Master Daemon Died</span><br><span class="line">14:59:19  The Master Daemon Died</span><br><span class="line">14:59:19  The Master Daemon Died</span><br><span class="line">14:59:19  invoke_alarm(): /bin/sh -c &#x27;/opt/install/g300/etc/alarmprogram.sh 5 6 &quot;Internal Subsystem failure: &#x27;MT&#x27;&quot; &quot;The Master Daemon Died&quot; &quot;&quot; 6069&#x27;</span><br><span class="line">14:59:19  invoke_alarm(): /bin/sh -c &#x27;/opt/install/g300/etc/alarmprogram.sh 5 6 &quot;Internal Subsystem failure: &#x27;MT&#x27;&quot; &quot;The Master Daemon Died&quot; &quot;&quot; 6069&#x27;</span><br><span class="line">14:59:19  invoke_alarm(): /bin/sh -c &#x27;/opt/install/g300/etc/alarmprogram.sh 5 6 &quot;Internal Subsystem failure: &#x27;MT&#x27;&quot; &quot;The Master Daemon Died&quot; &quot;&quot; 6069&#x27;</span><br><span class="line">14:59:19  invoke_alarm(): mt_exec failed, status 32256, errno 0</span><br><span class="line">14:59:19  invoke_alarm(): mt_exec failed, status 32256, errno 0</span><br><span class="line">14:59:19  invoke_alarm(): mt_exec failed, status 32256, errno 0</span><br><span class="line">14:59:19  PANIC: Attempting to bring system down</span><br><span class="line">~                                                                                                                                                           </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><strong>当时的新主机日志如下：</strong></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line">14:40:46  Maximum server connections 1 </span><br><span class="line">14:40:46  Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 4, Llog used 0</span><br><span class="line"></span><br><span class="line">14:56:14  Checkpoint Completed:  duration was 0 seconds.</span><br><span class="line">14:56:14  Fri Dec  2 - loguniq 9, logpos 0x8295018, timestamp: 0x146498 Interval: 333</span><br><span class="line"></span><br><span class="line">14:56:14  Maximum server connections 1 </span><br><span class="line">14:56:14  Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 4, Llog used 0</span><br><span class="line"></span><br><span class="line">14:57:49  The SMX connection between high availability servers was closed because the</span><br><span class="line"> peer server was unresponsive for the timeout period (60 seconds times the</span><br><span class="line"> number of retries). </span><br><span class="line">14:58:39  DR: ping timeout</span><br><span class="line">14:58:39  DR: Receive error</span><br><span class="line">14:58:39  dr_secrcv thread : asfcode = -25582: oserr = 4: errstr = : Network connection is broken.</span><br><span class="line"> System error = 4.</span><br><span class="line">14:58:39  DR_ERR set to -1</span><br><span class="line">14:58:40  DR: Turned off on secondary server</span><br><span class="line">14:58:40  Skipping failover callback.</span><br><span class="line">14:58:41  Process exited with return code 126: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 15 &quot;Data Replication failure.&quot; &quot;DR: Turned off on secondary server&quot; &quot;&quot; 15001</span><br><span class="line">14:58:41  Logical Recovery has reached the transaction cleanup phase.</span><br><span class="line">14:58:42  Checkpoint Completed:  duration was 0 seconds.</span><br><span class="line">14:58:42  Fri Dec  2 - loguniq 9, logpos 0x8297018, timestamp: 0x1464a6 Interval: 334</span><br><span class="line"></span><br><span class="line">14:58:42  Maximum server connections 1 </span><br><span class="line">14:58:42  Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 0, Llog used 1</span><br><span class="line"></span><br><span class="line">14:58:42  Logical Recovery Complete.</span><br><span class="line">          648 Committed, 0 Rolled Back, 0 Open, 0 Bad Locks</span><br><span class="line"></span><br><span class="line">14:58:42  Logical Recovery Complete.</span><br><span class="line">14:58:42  Quiescent Mode</span><br><span class="line">14:58:42  Checkpoint Completed:  duration was 0 seconds.</span><br><span class="line">14:58:42  Fri Dec  2 - loguniq 9, logpos 0x8299018, timestamp: 0x146591 Interval: 335</span><br><span class="line"></span><br><span class="line">14:58:42  Maximum server connections 1 </span><br><span class="line">14:58:42  Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 7, Llog used 2</span><br><span class="line"></span><br><span class="line">14:58:42  On-Line Mode</span><br><span class="line">14:58:42  Defragmenter cleaner thread now running</span><br><span class="line">14:58:42  Defragmenter cleaner thread cleaned:0 partitions</span><br><span class="line">14:58:43  SCHAPI: &quot;GBASEDBTDIR/etc/sysadmin/stop&quot; file is present.</span><br><span class="line">          Bypassing dbScheduler and dbWorker threads startup.</span><br><span class="line">14:58:43  B-tree scanners enabled.</span><br><span class="line">14:58:43  DR: Reservation of the last logical log for log backup turned on</span><br><span class="line">14:58:43  SCHAPI: &quot;GBASEDBTDIR/etc/sysadmin/stop&quot; file is present.</span><br><span class="line">          Bypassing dbScheduler and dbWorker threads startup.</span><br><span class="line">14:58:44  DR: new type = standard</span><br><span class="line">14:59:15  DR: Secondary server connected</span><br><span class="line">14:59:17  DR: Receive error</span><br><span class="line">14:59:17  dr_secrcv thread : asfcode = -25582: oserr = 0: errstr = : Network connection is broken.</span><br><span class="line"></span><br><span class="line">14:59:17  DR_ERR set to -1</span><br><span class="line">14:59:17  DR: Failure recovery error (2)</span><br><span class="line">14:59:17  DR: Log Record Apply Thread Exited.</span><br><span class="line">14:59:17  DR: Turned off on secondary server</span><br><span class="line">14:59:17  Process exited with return code 126: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 15 &quot;Data Replication failure.&quot; &quot;DR: Turned off on secondary server&quot; &quot;&quot; 15001</span><br><span class="line">14:59:17  DR: Standard to Standard</span><br><span class="line">14:59:17  SCHAPI: &quot;GBASEDBTDIR/etc/sysadmin/stop&quot; file is present.</span><br><span class="line">          Bypassing dbScheduler and dbWorker threads startup.</span><br><span class="line">14:59:17  DR: new type = standard</span><br><span class="line">15:04:02  Checkpoint Completed:  duration was 0 seconds.</span><br><span class="line">15:04:02  Fri Dec  2 - loguniq 9, logpos 0x829c018, timestamp: 0x1465a8 Interval: 336</span><br><span class="line"></span><br><span class="line">15:04:02  Maximum server connections 1 </span><br></pre></td></tr></table></figure>



<h3 id="最终结论"><a href="#最终结论" class="headerlink" title="最终结论"></a>最终结论</h3><ol>
<li><p>db_group的特点</p>
<ul>
<li>db_group只会找主或标准实例，绝对不会找备(SDS或HDR或RSS).</li>
<li>如果db_group在组里面有多主的时候，只连接第1个，第1个不通再连第2个。</li>
<li>db_group只可以解决连接问题，切换问题还需要配合DRAUTO来实现。</li>
</ul>
</li>
<li><p>cm的特点</p>
<ul>
<li><p>cm应该放在第3个节点上，这样它知道具体是哪个节点断网了。</p>
</li>
<li><p>cm放在和备节点一起的毛病是，备机掉网了，备数据库会变成主（因为cm到备库是通的，同时到主库是不通的）。</p>
</li>
</ul>
</li>
</ol>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/jdbc/" rel="tag">jdbc</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%BF%9E%E6%8E%A5%E4%B8%B2/" rel="tag">连接串</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%AB%98%E5%8F%AF%E7%94%A8/" rel="tag">高可用</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s关于DBSpaces自动扩容的测试"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8s%E5%85%B3%E4%BA%8EDBSpaces%E8%87%AA%E5%8A%A8%E6%89%A9%E5%AE%B9%E7%9A%84%E6%B5%8B%E8%AF%95/"
    >GBase8s关于DBSpaces自动扩容的测试</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E5%85%B3%E4%BA%8EDBSpaces%E8%87%AA%E5%8A%A8%E6%89%A9%E5%AE%B9%E7%9A%84%E6%B5%8B%E8%AF%95/" class="article-date">
  <time datetime="2023-05-10T01:28:11.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="自动扩容参数"><a href="#自动扩容参数" class="headerlink" title="自动扩容参数"></a>自动扩容参数</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Storage Provisioning Parameters</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SP_AUTOEXPAND - When <span class="built_in">set</span> to 1, GBase will automatically <span class="built_in">expand</span> spaces</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                that are low on or out of free pages. Set this param</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                to 0 to <span class="built_in">disable</span> automatic chunk extensions and chunk</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                additions.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                Default value is 1 (enabled).</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SP_THRESHOLD  - Minimum amount of free space <span class="keyword">in</span> a DBspace, BLOBspace,</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                or Smart BLOBspace before the space will automatically</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                be expanded. Value is a decimal, and can be an absolute</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                number of kilobytes or a percentage of the total size</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                <span class="keyword">in</span> the DBspace.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                Default value is 0, <span class="built_in">which</span> effectively disables this</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                proactive storage provisioning trigger.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SP_WAITTIME   - Access to the storage pool is serialized. When one thread</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                is accessing the storage pool, SP_WAITIME is the number of</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                seconds another thread will <span class="built_in">wait</span> before giving up on</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                its own access.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">                Default value is 30.</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">###################################################################</span></span></span><br><span class="line"></span><br><span class="line">SP_AUTOEXPAND 1</span><br><span class="line">SP_THRESHOLD 0</span><br><span class="line">SP_WAITTIME 30</span><br></pre></td></tr></table></figure>

<p>中文翻译：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">存储发放参数</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SP_AUTOEXPAND -当设置为1时，GBase将自动扩展空闲页面上或空闲页面外的低空间。将此参数设置为0以禁用自动块扩展和块添加。</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">默认值为1(启用)。</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SP_THRESHOLD - DBspace、BLOBspace或Smart BLOBspace在空间自动扩展之前的最小可用空间量。Value是一个小数，可以是千字节的绝对值(单位K)，也可以是DBspace中总大小的百分比。</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">默认值为0，这有效地禁用了这个主动存储供应触发器。</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SP_WAITTIME -对存储池的访问是序列化的。当一个线程正在访问存储池时，SP_WAITIME是另一个线程在放弃自己的访问之前等待的秒数。</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">默认值为30。</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">###################################################################</span></span></span><br></pre></td></tr></table></figure>

<p>扩展SP_THRESHOLD:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">onconfig.std value</span><br><span class="line">    SP_THRESHOLD 0</span><br><span class="line">values</span><br><span class="line">    0 = No threshold. The trigger that runs the storage space monitoring (mon_low_storage) task for adding space when space is below the threshold is disabled.</span><br><span class="line"></span><br><span class="line">    1 - 50 = A threshold that is a percentage of free kilobytes in a storage space.</span><br><span class="line"></span><br><span class="line">    If the value is 50 or below, Informix interprets the value as a percentage (for example, 10 = 10 percent and 2.84 = 2.84 percent).</span><br><span class="line"></span><br><span class="line">    1000 to the maximum size of a chunk = A threshold that is either 1000 kilobytes or the maximum size of the chunk on the current platform.</span><br><span class="line"></span><br><span class="line">    If the value is 1000 or higher, Informix interprets the value as a specific number of kilobytes.</span><br><span class="line"></span><br><span class="line">    Values 50 - 1000 are not valid.</span><br><span class="line">takes effect</span><br><span class="line">    After you edit your onconfig file and restart the database server.</span><br><span class="line">    When you reset the value dynamically in your onconfig file by running the onmode -wf command.</span><br><span class="line">    When you reset the value in memory by running the onmode -wm command.</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>扩展SP_THRESHOLD中文翻译：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">SP_THRESHOLD 0</span></span><br><span class="line"></span><br><span class="line">0 =无阈值。当空间低于阈值时，运行存储空间监控(mon_low_storage)任务(用于添加空间)的触发器被禁用。</span><br><span class="line"></span><br><span class="line">1 - 50 =一个阈值，它是存储空间中可用千字节的百分比。</span><br><span class="line"></span><br><span class="line">50 - 1000无效。</span><br><span class="line"></span><br><span class="line">1000-CHUNK最大值 =一个阈值，该阈值为1000千字节或当前平台上CHUNK的最大大小。</span><br><span class="line">如果该值为1000或更高，Informix将该值解释为特定的千字节数。</span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="个人小结"><a href="#个人小结" class="headerlink" title="个人小结"></a>个人小结</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">SP_AUTOEXPAND 1 </span><br><span class="line">SP_THRESHOLD 0</span><br><span class="line">SP_WAITTIME 30</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">开启存储发放，关闭空间监控和空间监控触发的扩容。如果其他空间真在扩容，最大等待30秒。</span></span><br></pre></td></tr></table></figure>



<h2 id="存储发放测试1：-SP-THRESHOLD-0"><a href="#存储发放测试1：-SP-THRESHOLD-0" class="headerlink" title="存储发放测试1： SP_THRESHOLD 0"></a>存储发放测试1： SP_THRESHOLD 0</h2><h3 id="参数"><a href="#参数" class="headerlink" title="参数"></a>参数</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">SP_AUTOEXPAND 1 </span><br><span class="line">SP_THRESHOLD 0</span><br><span class="line">SP_WAITTIME 30</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">开启存储发放，关闭空间监控和空间监控触发的扩容。如果其他空间真正扩容，最大等待30秒。</span></span><br></pre></td></tr></table></figure>

<h3 id="创建10M的DBS：dbs10"><a href="#创建10M的DBS：dbs10" class="headerlink" title="创建10M的DBS：dbs10"></a>创建10M的DBS：dbs10</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">touch /home/gbasedbt/dbs10330</span><br><span class="line">chmod 660 /home/gbasedbt/dbs10330</span><br><span class="line">onspaces -c -d dbs10 -p /home/gbasedbt/dbs10330 -o 0 -s 10240 </span><br></pre></td></tr></table></figure>

<h3 id="创建数据库存在其上：-db10"><a href="#创建数据库存在其上：-db10" class="headerlink" title="创建数据库存在其上：  db10"></a>创建数据库存在其上：  db10</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">dbaccess sysmaster &lt;&lt;!</span><br><span class="line">	create database db10 in dbs10;</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="创建测试表：-t"><a href="#创建测试表：-t" class="headerlink" title="创建测试表： t"></a>创建测试表： t</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db10 &lt;&lt;!</span><br><span class="line">	drop table if exists t;</span><br><span class="line">    create table t(</span><br><span class="line">    id   serial not null,</span><br><span class="line">    col1 datetime year to second default current year to second,</span><br><span class="line">    col2 char(200),</span><br><span class="line">    col3 varchar(200),</span><br><span class="line">    primary key(id)</span><br><span class="line">);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="在测试表里插入大量数据："><a href="#在测试表里插入大量数据：" class="headerlink" title="在测试表里插入大量数据："></a>在测试表里插入大量数据：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db10 &lt;&lt;!</span><br><span class="line">drop procedure if exists insert_t;</span><br><span class="line">create procedure insert_t()</span><br><span class="line">	define i int;</span><br><span class="line">	for i=1 to 30000</span><br><span class="line">		insert into t(col2,col3) values (&#x27;zgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8l&#x27;,&#x27;7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8F&#x27;);</span><br><span class="line">	end for;</span><br><span class="line">end procedure;</span><br><span class="line">call insert_t();</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="插入过程会失败：报错131"><a href="#插入过程会失败：报错131" class="headerlink" title="插入过程会失败：报错131"></a>插入过程会失败：报错131</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">  271: 不能将新行插入表内。</span><br><span class="line"></span><br><span class="line">  131: ISAM 错误：没有可用磁盘空间</span><br><span class="line">错误在 1 行</span><br><span class="line">第 1 字符</span><br></pre></td></tr></table></figure>

<h3 id="再次插入：还是报错131"><a href="#再次插入：还是报错131" class="headerlink" title="再次插入：还是报错131"></a>再次插入：还是报错131</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db10 &lt;&lt;!</span><br><span class="line">	create table t1 (id int);</span><br><span class="line">	insert into t1 values(1);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">12:34:06  WARNING: DBspace dbs10 is full</span><br><span class="line">12:34:06  Process exited with return code 127: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 44 &quot;DBSpace is full: &#x27;dbs10&#x27;&quot; </span><br><span class="line">&quot;WARNING: DBspace dbs10 is full&quot; &quot;&quot; 44001</span><br><span class="line">12:35:25  Checkpoint Completed:  duration was 0 seconds.</span><br></pre></td></tr></table></figure>

<h3 id="测试结果："><a href="#测试结果：" class="headerlink" title="测试结果："></a>测试结果：</h3><p>​		空间满报错，不能插入。</p>
<h2 id="存储发放测试2：SP-THRESHOLD-10"><a href="#存储发放测试2：SP-THRESHOLD-10" class="headerlink" title="存储发放测试2：SP_THRESHOLD 10"></a>存储发放测试2：SP_THRESHOLD 10</h2><h3 id="参数调整"><a href="#参数调整" class="headerlink" title="参数调整"></a>参数调整</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">SP_AUTOEXPAND 1 </span><br><span class="line">SP_THRESHOLD 10</span><br><span class="line">SP_WAITTIME 30</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">开启存储发放，关闭空间监控和空间监控触发的扩容。如果其他空间真正扩容，最大等待30秒。</span></span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">onmode -wf SP_THRESHOLD=10</span><br></pre></td></tr></table></figure>

<p>注明：测发现对之前已经满了的dbs没有效果，插入还是报错。</p>
<h3 id="创建10M的DBS：dbs106"><a href="#创建10M的DBS：dbs106" class="headerlink" title="创建10M的DBS：dbs106"></a>创建10M的DBS：dbs106</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">touch /home/gbasedbt/dbs106</span><br><span class="line">chmod 660 /home/gbasedbt/dbs106</span><br><span class="line">onspaces -c -d dbs106 -p /home/gbasedbt/dbs106 -o 0 -s 10240 </span><br></pre></td></tr></table></figure>

<h3 id="创建数据库存在其上：-db106"><a href="#创建数据库存在其上：-db106" class="headerlink" title="创建数据库存在其上：  db106"></a>创建数据库存在其上：  db106</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">dbaccess sysmaster &lt;&lt;!</span><br><span class="line">	create database db106 in dbs106;</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="创建测试表：-t-1"><a href="#创建测试表：-t-1" class="headerlink" title="创建测试表： t"></a>创建测试表： t</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db106 &lt;&lt;!</span><br><span class="line">	drop table if exists t;</span><br><span class="line">    create table t(</span><br><span class="line">    id   serial not null,</span><br><span class="line">    col1 datetime year to second default current year to second,</span><br><span class="line">    col2 char(200),</span><br><span class="line">    col3 varchar(200),</span><br><span class="line">    primary key(id)</span><br><span class="line">    );</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="在测试表里插入大量数据：-1"><a href="#在测试表里插入大量数据：-1" class="headerlink" title="在测试表里插入大量数据："></a>在测试表里插入大量数据：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db106 &lt;&lt;!</span><br><span class="line">drop procedure if exists insert_t;</span><br><span class="line">create procedure insert_t()</span><br><span class="line">	define i int;</span><br><span class="line">	for i=1 to 30000</span><br><span class="line">		insert into t(col2,col3) values (&#x27;zgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8l&#x27;,&#x27;7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8F&#x27;);</span><br><span class="line">	end for;</span><br><span class="line">end procedure;</span><br><span class="line">call insert_t();</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="插入过程会失败：报错131-1"><a href="#插入过程会失败：报错131-1" class="headerlink" title="插入过程会失败：报错131"></a>插入过程会失败：报错131</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">  271: 不能将新行插入表内。</span><br><span class="line"></span><br><span class="line">  131: ISAM 错误：没有可用磁盘空间</span><br><span class="line">错误在 1 行</span><br><span class="line">第 1 字符</span><br></pre></td></tr></table></figure>

<h3 id="再次插入：还是报错131-1"><a href="#再次插入：还是报错131-1" class="headerlink" title="再次插入：还是报错131"></a>再次插入：还是报错131</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db106 &lt;&lt;!</span><br><span class="line">	create table t1 (id int);</span><br><span class="line">	insert into t1 values(1);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">12:34:06  WARNING: DBspace dbs10 is full</span><br><span class="line">12:34:06  Process exited with return code 127: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 44 &quot;DBSpace is full: &#x27;dbs10&#x27;&quot; </span><br><span class="line">&quot;WARNING: DBspace dbs10 is full&quot; &quot;&quot; 44001</span><br><span class="line">12:35:25  Checkpoint Completed:  duration was 0 seconds.</span><br></pre></td></tr></table></figure>

<h3 id="测试结果：-1"><a href="#测试结果：-1" class="headerlink" title="测试结果："></a>测试结果：</h3><p>​		测试发现对新建的dbs也没有效果，插入还是报错。</p>
<p>​		发现sysadmin么有启动。</p>
<h2 id="存储发放测试3：启用sysadmin"><a href="#存储发放测试3：启用sysadmin" class="headerlink" title="存储发放测试3：启用sysadmin"></a>存储发放测试3：启用sysadmin</h2><h3 id="启用sysadmin"><a href="#启用sysadmin" class="headerlink" title="启用sysadmin"></a>启用sysadmin</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">rm $GBASEDBTDIR/etc/sysadmin/stop</span><br><span class="line">onmode -ky ; </span><br><span class="line">sleep 3;</span><br><span class="line">oninit -v;</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">95       4b61cb50         474ae868         1    sleeping secs: 285      9cpu         dbScheduler</span><br><span class="line">96       4b67b028         474adfa8         1    sleeping forever        9cpu         dbWorker1</span><br><span class="line">97       4b410028         474af128         1    sleeping forever        9cpu         dbWorker2</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">12:59:51  WARNING: DBspace dbs10 is full</span><br><span class="line">12:59:51  Process exited with return code 127: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 44 &quot;DBSpace is full: &#x27;dbs10&#x27;&quot; </span><br><span class="line">&quot;WARNING: DBspace dbs10 is full&quot; &quot;&quot; 44001</span><br><span class="line">13:00:23  Loading Module &lt;$GBASEDBTDIR/extend/ifxmngr/ifxmngr.bld&gt;</span><br><span class="line">13:00:23  pid 2316: can&#x27;t get real path of linux-vdso.so.1</span><br><span class="line">13:00:23  pid 2316: ELF .eh_frame section missing in /opt/install/g300/gls/dll/64-libicudata.so.48</span><br><span class="line">13:00:23  The C Language Module &lt;/opt/install/g300/extend/ifxmngr/ifxmngr.bld&gt; loaded</span><br><span class="line">13:02:41  Audit trail switched to /home/gbasedbt/audit_log/g300.28</span><br><span class="line">13:02:41  Process exited with return code 127: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 2 72 &quot;Audit trail switched to Audit&quot; &quot;Audit trail switched to /home/gbasedbt/audit_log/g300.28&quot; &quot;&quot; 72001</span><br><span class="line">13:02:50  WARNING: DBspace dbs106 is full</span><br><span class="line">13:02:50  Process exited with return code 127: /bin/sh /bin/sh -c /opt/install/g300/etc/alarmprogram.sh 3 44 &quot;DBSpace is full: &#x27;dbs106&#x27;&quot; &quot;WARNING: DBspace dbs106 is full&quot; &quot;&quot; 44001</span><br></pre></td></tr></table></figure>



<h3 id="测试结果：-2"><a href="#测试结果：-2" class="headerlink" title="测试结果："></a>测试结果：</h3><p>​		测试发现插入还是报错空间满了。</p>
<h2 id="存储发放测试4：把dbs创建到和rootdbs同目录下试试"><a href="#存储发放测试4：把dbs创建到和rootdbs同目录下试试" class="headerlink" title="存储发放测试4：把dbs创建到和rootdbs同目录下试试"></a>存储发放测试4：把dbs创建到和rootdbs同目录下试试</h2><h3 id="把dbs创建到和rootdbs同目录下试试"><a href="#把dbs创建到和rootdbs同目录下试试" class="headerlink" title="把dbs创建到和rootdbs同目录下试试"></a>把dbs创建到和rootdbs同目录下试试</h3><h3 id="创建10M的DBS：dbs10-1"><a href="#创建10M的DBS：dbs10-1" class="headerlink" title="创建10M的DBS：dbs10"></a>创建10M的DBS：dbs10</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">touch /data/g300/rootchkdbs</span><br><span class="line">chmod 660 /data/g300/rootchkdbs</span><br><span class="line">onspaces -c -d dbs10r -p /data/g300/rootchkdbs -o 0 -s 10240 </span><br></pre></td></tr></table></figure>

<h3 id="创建数据库存在其上：-db10-1"><a href="#创建数据库存在其上：-db10-1" class="headerlink" title="创建数据库存在其上：  db10"></a>创建数据库存在其上：  db10</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">dbaccess sysmaster &lt;&lt;!</span><br><span class="line">	create database db10r in dbs10r;</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="创建测试表：-t-2"><a href="#创建测试表：-t-2" class="headerlink" title="创建测试表： t"></a>创建测试表： t</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db10r &lt;&lt;!</span><br><span class="line">	drop table if exists t;</span><br><span class="line">    create table t(</span><br><span class="line">    id   serial not null,</span><br><span class="line">    col1 datetime year to second default current year to second,</span><br><span class="line">    col2 char(200),</span><br><span class="line">    col3 varchar(200),</span><br><span class="line">    primary key(id)</span><br><span class="line">);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="在测试表里插入大量数据：-2"><a href="#在测试表里插入大量数据：-2" class="headerlink" title="在测试表里插入大量数据："></a>在测试表里插入大量数据：</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db10r &lt;&lt;!</span><br><span class="line">drop procedure if exists insert_t;</span><br><span class="line">create procedure insert_t()</span><br><span class="line">	define i int;</span><br><span class="line">	for i=1 to 30000</span><br><span class="line">		insert into t(col2,col3) values (&#x27;zgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8FDBZ7dkBUdX8l&#x27;,&#x27;7dkBUdX8liWERZzgCdw31DZpyToUdqrszWXt8F&#x27;);</span><br><span class="line">	end for;</span><br><span class="line">end procedure;</span><br><span class="line">call insert_t();</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<h3 id="插入过程会失败：报错131-2"><a href="#插入过程会失败：报错131-2" class="headerlink" title="插入过程会失败：报错131"></a>插入过程会失败：报错131</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">  271: 不能将新行插入表内。</span><br><span class="line"></span><br><span class="line">  131: ISAM 错误：没有可用磁盘空间</span><br><span class="line">错误在 1 行</span><br><span class="line">第 1 字符</span><br></pre></td></tr></table></figure>

<h3 id="测试结果：-3"><a href="#测试结果：-3" class="headerlink" title="测试结果："></a>测试结果：</h3><p>​		空间满报错，不能插入。</p>
<hr>
<h2 id="故障点1：-需要先配置存储池，才能启用自动扩容（文件系统chunk除外）。"><a href="#故障点1：-需要先配置存储池，才能启用自动扩容（文件系统chunk除外）。" class="headerlink" title="故障点1： 需要先配置存储池，才能启用自动扩容（文件系统chunk除外）。"></a>故障点1： 需要先配置存储池，才能启用自动扩容（文件系统chunk除外）。</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">13:37:08  SCHAPI Estimate succeeded for table &#x27;db10:&quot;gbasedbt&quot;. t&#x27; partnum a00047. </span><br><span class="line">13:37:08  admin_fragment_command(&#x27;fragment estimate_compression &#x27;,&#x27;10485831&#x27;) succeeded </span><br><span class="line">13:37:16  Warning: The storage pool is out of space. To enable automatic chunk  creation use the OpenAdmin Tool to add space to the pool. </span><br><span class="line">13:37:17  WARNING: DBspace dbs10 is full </span><br><span class="line">13:37:17  Process exited with return code 127: /bin/sh /bin/sh -c /opt/install/g330/etc/alarmprogram.sh 3 78 &quot;Warning: The storage pool is out of space. To enable automatic chunk </span><br><span class="line">          creation use the OpenAdmin Tool to add space to the pool.&quot; &quot;Warning: The storage pool is out of space. To enable automatic chunk </span><br><span class="line">          creation use the OpenAdmin Tool to add space to the pool.&quot; &quot;&quot; 78001 </span><br><span class="line">13:37:17  Process exited with return code 127: /bin/sh /bin/sh -c /opt/install/g330/etc/alarmprogram.sh 3 44 &quot;DBSpace is full: &#x27;dbs10&#x27;&quot; &quot;WARNING: DBspace dbs10 is full&quot; &quot;&quot; 44001 </span><br><span class="line">13:37:49  Loading Module &lt;$GBASEDBTDIR/extend/ifxmngr/ifxmngr.bld&gt; </span><br><span class="line">13:37:49  pid 2689: can&#x27;t get real path of linux-vdso.so.1 </span><br><span class="line">13:37:49  pid 2689: ELF .eh_frame section missing in /opt/install/g330/gls/dll/64-libicudata.so.48 </span><br><span class="line">13:37:50  The C Language Module &lt;/opt/install/g330/extend/ifxmngr/ifxmngr.bld&gt; loaded</span><br></pre></td></tr></table></figure>



<h2 id="故障点2：-chunk需要标记为可扩展"><a href="#故障点2：-chunk需要标记为可扩展" class="headerlink" title="故障点2： chunk需要标记为可扩展"></a>故障点2： chunk需要标记为可扩展</h2><hr>
<h2 id="请参考官方文档"><a href="#请参考官方文档" class="headerlink" title="请参考官方文档"></a>请参考官方文档</h2><p><a target="_blank" rel="noopener" href="https://www.ibm.com/docs/en/informix-servers/12.10?topic=management-marking-chunk-as-extendable-not-extendable">修改chunk可自动扩容</a></p>
<p><a target="_blank" rel="noopener" href="https://www.ibm.com/docs/en/informix-servers/12.10?topic=management-manually-expanding-space-extending-extendable-chunk#ids_admin_1368">扩容dbs或扩容chunk的API</a></p>
<p><a target="_blank" rel="noopener" href="https://www.ibm.com/docs/en/informix-servers/12.10?topic=space-automatic-management">INFORMIX自动空间管理 指导</a></p>
<h2 id="存款发放测试5："><a href="#存款发放测试5：" class="headerlink" title="存款发放测试5："></a>存款发放测试5：</h2><h3 id="标记chunk为可扩展"><a href="#标记chunk为可扩展" class="headerlink" title="标记chunk为可扩展"></a>标记chunk为可扩展</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line">root@wei66:~# su - gbasedbt </span><br><span class="line">gbasedbt@wei66:~$ dbaccess sysadmin -</span><br><span class="line"></span><br><span class="line">数据库已被选用。</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">EXECUTE FUNCTION task(<span class="string">&quot;modify chunk extendable&quot;</span>, <span class="string">&quot;11&quot;</span>);</span>  </span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">(expression)  Chunk 11 is now extendable. </span><br><span class="line"></span><br><span class="line">查询到 1 行。</span><br><span class="line"></span><br><span class="line">Elapsed time: 0.202 sec</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash"></span></span><br><span class="line"><span class="language-bash"></span></span><br><span class="line">数据库已关闭。</span><br><span class="line"></span><br><span class="line">gbasedbt@wei66:~$ onstat -d</span><br><span class="line"></span><br><span class="line">GBase Database Server Version 12.10.FC4G1AEE -- On-Line -- Up 00:11:04 -- 930724 Kbytes</span><br><span class="line"></span><br><span class="line">Dbspaces</span><br><span class="line">address          number   flags      fchunk   nchunks  pgsize   flags    owner    name</span><br><span class="line">4737f028         1        0x60001    1        1        2048     N  BA    gbasedbt rootdbs</span><br><span class="line">49b60dc8         2        0x40001    2        1        2048     N  BA    gbasedbt plogdbs</span><br><span class="line">4a193028         3        0x40001    3        1        2048     N  BA    gbasedbt llogdbs</span><br><span class="line">4a193258         4        0x42001    4        1        2048     N TBA    gbasedbt tempdbs01</span><br><span class="line">4a193488         5        0x42001    5        1        2048     N TBA    gbasedbt tempdbs02</span><br><span class="line">4a1936b8         6        0x42001    6        1        2048     N TBA    gbasedbt tempdbs03</span><br><span class="line">4a1938e8         7        0x42001    7        1        2048     N TBA    gbasedbt tempdbs04</span><br><span class="line">4a193b18         8        0x48001    8        1        2048     N SBA    gbasedbt sbspace01</span><br><span class="line">4a193d48         9        0x40001    9        1        2048     N  BA    gbasedbt datadbs01</span><br><span class="line">4a195028         10       0x40001    10       1        16384    N  BA    gbasedbt datadbs02</span><br><span class="line">4a195258         11       0x60001    11       1        2048     N  BA    gbasedbt dbs10</span><br><span class="line">4a195488         12       0x60001    12       1        2048     N  BA    gbasedbt dbs106</span><br><span class="line">4a1956b8         13       0x60001    13       1        2048     N  BA    gbasedbt dbs10r</span><br><span class="line"> 13 active, 2047 maximum</span><br><span class="line"></span><br><span class="line">Chunks</span><br><span class="line">address          chunk/dbs     offset     size       free       bpages     flags pathname</span><br><span class="line">4737f258         1      1      0          512000     498465                PO-B-D /data/g300/rootchk</span><br><span class="line">4a196028         2      2      0          512000     11947                 PO-B-D /data/g300/plogchk</span><br><span class="line">4a197028         3      3      0          512000     11947                 PO-B-D /data/g300/llogchk</span><br><span class="line">4a198028         4      4      0          512000     511947                PO-B-- /data/g300/tempchk01</span><br><span class="line">4a199028         5      5      0          512000     511947                PO-B-- /data/g300/tempchk02</span><br><span class="line">4a19a028         6      6      0          512000     511947                PO-B-- /data/g300/tempchk03</span><br><span class="line">4a19b028         7      7      0          512000     511947                PO-B-- /data/g300/tempchk04</span><br><span class="line">4a19c028         8      8      0          512000     451866     451868     POSB-D /data/g300/sbspace01</span><br><span class="line">                                 Metadata 60079      0          60079   </span><br><span class="line">4a19d028         9      9      0          512000     490456                PO-B-D /data/g300/datachk01</span><br><span class="line">4a19e028         10     10     0          6400       5809                  PO-B-D /data/g300/datachk02</span><br><span class="line">4a19f028         11     11     0          5120       0                     PO-BED /home/gbasedbt/dbs10</span><br><span class="line">4a1a0028         12     12     0          5120       0                     PO-B-D /home/gbasedbt/dbs106</span><br><span class="line">4a1a1028         13     13     0          5120       0                     PO-B-D /data/g300/rootchkdbs</span><br><span class="line"> 13 active, 32766 maximum</span><br><span class="line"></span><br><span class="line">NOTE: The values in the &quot;size&quot; and &quot;free&quot; columns for DBspace chunks are</span><br><span class="line">      displayed in terms of &quot;pgsize&quot; of the DBspace to which they belong.</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">Expanded chunk capacity mode: always</span><br><span class="line"></span><br><span class="line">gbasedbt@wei66:~$ </span><br></pre></td></tr></table></figure>

<h3 id="再次插入：成功"><a href="#再次插入：成功" class="headerlink" title="再次插入：成功"></a>再次插入：成功</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db10 &lt;&lt;!</span><br><span class="line">	create table t1 (id int);</span><br><span class="line">	insert into t1 values(1);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">插入成功，且11号chunk自动扩容5000页：</span></span><br><span class="line">4a19e028         10     10     0          6400       5809                  PO-B-D /data/g300/datachk02</span><br><span class="line">4a19f028         11     11     0          10120      4992                  PO-BED /home/gbasedbt/dbs10</span><br><span class="line">4a1a0028         12     12     0          5120       0                     PO-B-D /home/gbasedbt/dbs106</span><br><span class="line">4a1a1028         13     13     0          5120       0                     PO-B-D /data/g300/rootchkdbs</span><br></pre></td></tr></table></figure>

<h3 id="测试结果：-4"><a href="#测试结果：-4" class="headerlink" title="测试结果："></a>测试结果：</h3><p>​		空间自动扩容。</p>
<h2 id="存储发放测试6：关闭sysadmin后自动扩容是否好使"><a href="#存储发放测试6：关闭sysadmin后自动扩容是否好使" class="headerlink" title="存储发放测试6：关闭sysadmin后自动扩容是否好使"></a>存储发放测试6：关闭sysadmin后自动扩容是否好使</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">dbaccess sysadmin &lt;&lt;!</span><br><span class="line">-- EXECUTE FUNCTION task(&quot;modify chunk extendable&quot;, &quot;11&quot;);  </span><br><span class="line">EXECUTE FUNCTION task(&quot;modify chunk extendable&quot;, &quot;12&quot;);</span><br><span class="line">EXECUTE FUNCTION task(&quot;modify chunk extendable&quot;, &quot;13&quot;);</span><br><span class="line">! </span><br><span class="line"></span><br><span class="line">touch $GBASEDBTDIR/etc/sysadmin/stop</span><br><span class="line">onmode -ky ; </span><br><span class="line">sleep 3;</span><br><span class="line">oninit -v;</span><br></pre></td></tr></table></figure>

<h3 id="再次插入：成功-1"><a href="#再次插入：成功-1" class="headerlink" title="再次插入：成功"></a>再次插入：成功</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db106 &lt;&lt;!</span><br><span class="line">	create table t1 (id int);</span><br><span class="line">	insert into t1 values(1);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">gbasedbt@wei66:~$ onstat -g ath |grep -i work</span><br><span class="line">gbasedbt@wei66:~$ onstat -d |awk &#x27;$2==&quot;12&quot;&#x27;</span><br><span class="line">4a18f028         12     12     0          10120      4992                  PO-BED /home/gbasedbt/dbs106</span><br></pre></td></tr></table></figure>

<h3 id="测试结果：-5"><a href="#测试结果：-5" class="headerlink" title="测试结果："></a>测试结果：</h3><p>​		空间自动扩容。</p>
<p>​		</p>
<h2 id="存储发放测试7：SP-THRESHOLD-0"><a href="#存储发放测试7：SP-THRESHOLD-0" class="headerlink" title="存储发放测试7：SP_THRESHOLD 0"></a>存储发放测试7：SP_THRESHOLD 0</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">dbaccess sysadmin &lt;&lt;!</span><br><span class="line">EXECUTE FUNCTION task(&quot;modify chunk extendable off&quot;, &quot;13&quot;);</span><br><span class="line">EXECUTE FUNCTION task(&quot;modify chunk extendable&quot;, &quot;13&quot;);</span><br><span class="line">! </span><br><span class="line"></span><br><span class="line">onmode -wf SP_THRESHOLD=0</span><br><span class="line">onmode -ky ; </span><br><span class="line">sleep 3;</span><br><span class="line">oninit -v;</span><br></pre></td></tr></table></figure>

<h3 id="再次插入：成功-2"><a href="#再次插入：成功-2" class="headerlink" title="再次插入：成功"></a>再次插入：成功</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dbaccess db10r &lt;&lt;!</span><br><span class="line">	create table t1 (id int);</span><br><span class="line">	insert into t1 values(1);</span><br><span class="line">!</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">4a19f028         11     11     0          10120      4992                  PO-BED /home/gbasedbt/dbs10</span><br><span class="line">4a1a0028         12     12     0          10120      4992                  PO-BED /home/gbasedbt/dbs106</span><br><span class="line">4a1a1028         13     13     0          10120      4992                  PO-BED /data/g300/rootchkdbs</span><br></pre></td></tr></table></figure>

<h3 id="测试结果：-6"><a href="#测试结果：-6" class="headerlink" title="测试结果："></a>测试结果：</h3><p>​		空间自动扩容。</p>
<p>​		结论注明： 只要有sysadmin库存在即可。</p>
<h2 id="关于DBSpaces自动扩容的总结："><a href="#关于DBSpaces自动扩容的总结：" class="headerlink" title="关于DBSpaces自动扩容的总结："></a>关于DBSpaces自动扩容的总结：</h2><ol>
<li>自动扩容有两种，一种添加chunk，一种扩大chunk。</li>
<li>自动扩容第一步就是配置存储池。文件系统的chunk就不用配置存储池了，应为文件系统本身就是池。</li>
<li>需要sysadmin里面的api打开文件系统chunk的E开关。</li>
<li>sysadmin里面的任务可以stop不用启动，不会影响自动扩容。</li>
<li>SP_THRESHOLD可以设置为0，没有了要用到时再扩，不用事先监控并扩容。</li>
<li>sysadmin如果stop后，SP_THRESHOLD的task是不是也会不启作用了？</li>
<li>存储池的详细研究？</li>
</ol>
<p><strong>参考官方文档</strong>：</p>
<p><a target="_blank" rel="noopener" href="https://www.ibm.com/docs/en/informix-servers/12.10?topic=management-marking-chunk-as-extendable-not-extendable">修改chunk可自动扩容</a></p>
<p><a target="_blank" rel="noopener" href="https://www.ibm.com/docs/en/informix-servers/12.10?topic=management-manually-expanding-space-extending-extendable-chunk#ids_admin_1368">扩容dbs或扩容chunk的API</a></p>
<p><a target="_blank" rel="noopener" href="https://www.ibm.com/docs/en/informix-servers/12.10?topic=space-automatic-management">INFORMIX自动空间管理 指导</a></p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%87%AA%E5%8A%A8%E6%89%A9%E5%AE%B9/" rel="tag">自动扩容</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s内部用户可用限制会话数量"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8s%E5%86%85%E9%83%A8%E7%94%A8%E6%88%B7%E5%8F%AF%E7%94%A8%E9%99%90%E5%88%B6%E4%BC%9A%E8%AF%9D%E6%95%B0%E9%87%8F/"
    >GBase8s内部用户可用限制会话数量</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E5%86%85%E9%83%A8%E7%94%A8%E6%88%B7%E5%8F%AF%E7%94%A8%E9%99%90%E5%88%B6%E4%BC%9A%E8%AF%9D%E6%95%B0%E9%87%8F/" class="article-date">
  <time datetime="2023-05-10T01:27:21.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="内部用户的配置步骤"><a href="#内部用户的配置步骤" class="headerlink" title="内部用户的配置步骤"></a>内部用户的配置步骤</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">GBase 8s支持内部用户，但默认情况下并不是开启的，需要手工开启。</span><br><span class="line">以下以GBase 8s v8.8_2.0.1a2_2版本为例示范如何使用内部用户（mapping user)</span><br><span class="line"></span><br><span class="line">1，配置allowed.surrogates</span><br><span class="line">在/etc/gbasedbt（如没有，使用root用户创建）下创建allowed.surrogates配置文件，内容如下：</span><br><span class="line">USERS:daemon</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">2，使用gbasedbt用户执行以下命令，使数据库开启USERMAPPING</span><br><span class="line">onmode -wf USERMAPPING=ADMIN</span><br><span class="line"></span><br><span class="line">3，使用gbasedbt用户执行以下命令，加载surrogates到缓存</span><br><span class="line">onmode -cache surrogates</span><br><span class="line"></span><br><span class="line">4，在sysuser库中创建系统默认用户，可以指定默认目录(默认目录的权限为777)</span><br><span class="line">CREATE DEFAULT USER WITH PROPERTIES USER daemon HOME &quot;/home/gbase8t/users&quot; ;</span><br><span class="line"></span><br><span class="line">5，使用gbasedbt创建普通用户，并指定密码。</span><br><span class="line">注：密码需要符合安全密码要求(不少于8位，至少包含大写、小写字母，数字)</span><br><span class="line">CREATE USER dbtuser WITH PASSWORD &#x27;GBase123&#x27;;</span><br><span class="line"></span><br><span class="line">6，使用dba用户在数据库中赋权访问</span><br><span class="line">echo &quot;grant connect to dbtuser;&quot; | dbaccess testdb -</span><br><span class="line"></span><br><span class="line">7，使用内部用户访问数据库，按提示输入密码</span><br><span class="line">dbaccess - -</span><br><span class="line">CONNECT TO &#x27;testdb@gbase01&#x27; USER &#x27;dbtuser&#x27;;</span><br></pre></td></tr></table></figure>





<h2 id="内部用户可用限制会话数量"><a href="#内部用户可用限制会话数量" class="headerlink" title="内部用户可用限制会话数量"></a>内部用户可用限制会话数量</h2><h5 id="SESSION-PER-USER-子句"><a href="#SESSION-PER-USER-子句" class="headerlink" title="SESSION_PER_USER 子句"></a>SESSION_PER_USER 子句</h5><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">SESSION_PER_USER n：在一个实例中，一个用户可以同时拥有的会话数量，正整数，n 的取值范围为：[<span class="number">1</span>,<span class="number">231</span> <span class="number">-1</span>]。</span><br><span class="line"></span><br><span class="line"><span class="comment">--例如以下语句创建用户名为user1001，密码为123456，os_user为映射的操作系统用户，限制该用户的会话连接数为5：</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">USER</span> user1001 <span class="keyword">WITH</span> PASSWORD ‘<span class="number">123456</span>’ PROPERTIES <span class="keyword">USER</span> os_user SESSION_PER_USER <span class="number">5</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--如下即可：</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">USER</span> wangwei2 <span class="keyword">WITH</span> PASSWORD <span class="string">&#x27;GBase123&#x27;</span> PROPERTIES <span class="keyword">USER</span> daemon SESSION_PER_USER <span class="number">5</span>;</span><br><span class="line"></span><br><span class="line"><span class="comment">--如下即可：</span></span><br><span class="line">dbaccess sysuser <span class="operator">&lt;&lt;</span><span class="operator">!</span></span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">USER</span> wangwei3 <span class="keyword">WITH</span> PASSWORD <span class="string">&#x27;GBase123&#x27;</span> PROPERTIES <span class="keyword">USER</span> daemon SESSION_PER_USER <span class="number">50</span>;</span><br><span class="line"><span class="operator">!</span></span><br></pre></td></tr></table></figure>



<h5 id="测试连接数限制"><a href="#测试连接数限制" class="headerlink" title="测试连接数限制"></a>测试连接数限制</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.trey;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.alibaba.druid.pool.DruidDataSource;</span><br><span class="line"><span class="keyword">import</span> org.junit.jupiter.api.Test;</span><br><span class="line"><span class="keyword">import</span> org.springframework.boot.test.context.SpringBootTest;</span><br><span class="line"></span><br><span class="line"><span class="meta">@SpringBootTest</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">ConnectGBaseTestApplicationTests</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Test</span></span><br><span class="line">    <span class="keyword">void</span> <span class="title function_">contextLoads</span><span class="params">()</span> &#123;</span><br><span class="line">        <span class="type">DruidDataSource</span> <span class="variable">dataSource1</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">DruidDataSource</span>();</span><br><span class="line">        dataSource1.setDriverClassName(<span class="string">&quot;com.gbasedbt.jdbc.Driver&quot;</span>);</span><br><span class="line">        dataSource1.setUrl(<span class="string">&quot;jdbc:gbasedbt-sqli://1.1.1.2:9031/utf8:GBASEDBTSERVER=g31;CLIENT_LOCALE=zh_cn.utf8;DB_LOCALE=zh_cn.utf8;LOGINTIMEOUT=60000;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y;DBDATE=Y4MD&quot;</span>);</span><br><span class="line">        dataSource1.setUsername(<span class="string">&quot;wangwei3&quot;</span>);</span><br><span class="line">        dataSource1.setPassword(<span class="string">&quot;GBase123&quot;</span>);</span><br><span class="line">        dataSource1.setMaxActive(<span class="number">100</span>);</span><br><span class="line">        dataSource1.setInitialSize(<span class="number">100</span>);</span><br><span class="line">        dataSource1.setMinIdle(<span class="number">100</span>);</span><br><span class="line">        dataSource1.setTestWhileIdle(<span class="literal">false</span>);</span><br><span class="line">        </span><br><span class="line">        <span class="type">ExecutorService</span> <span class="variable">threadPool</span> <span class="operator">=</span> Executors.newCachedThreadPool();</span><br><span class="line">        threadPool.execute(() -&gt; &#123;</span><br><span class="line">            <span class="keyword">try</span> &#123;</span><br><span class="line">                dataSource1.getConnection();</span><br><span class="line">            &#125; <span class="keyword">catch</span> (SQLException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;);</span><br><span class="line">        System.out.println(<span class="string">&quot;100个链接在后台创建中...&quot;</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//主程序延时退出</span></span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            Thread.sleep(<span class="number">60000000</span>);</span><br><span class="line">        &#125; <span class="keyword">catch</span> (InterruptedException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<h5 id="当运行上面的测试时，链接数达到阈值后java程序回收到如下报错"><a href="#当运行上面的测试时，链接数达到阈值后java程序回收到如下报错" class="headerlink" title="当运行上面的测试时，链接数达到阈值后java程序回收到如下报错"></a>当运行上面的测试时，链接数达到阈值后java程序回收到如下报错</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">100</span>个链接在后台创建中...</span><br><span class="line"><span class="number">2023</span>-<span class="number">02</span>-<span class="number">03</span> <span class="number">19</span>:08:<span class="number">59.888</span> ERROR <span class="number">13156</span> --- [pool-<span class="number">1</span>-thread-<span class="number">1</span>] com.alibaba.druid.pool.DruidDataSource   : init datasource error, url: jdbc:gbasedbt-sqli:<span class="comment">//1.1.1.2:9031/utf8:GBASEDBTSERVER=g31;CLIENT_LOCALE=zh_cn.utf8;DB_LOCALE=zh_cn.utf8;LOGINTIMEOUT=60000;IFX_LOCK_MODE_WAIT=60;APPENDISAM=true;UPPER_CASE=y;DBDATE=Y4MD</span></span><br><span class="line"></span><br><span class="line">java.sql.SQLException: Cannot create a user thread.</span><br><span class="line">	at com.gbasedbt.jdbc.IfxSqliConnect.&lt;init&gt;(IfxSqliConnect.java:<span class="number">1436</span>) ~[gbasedbtjdbc_3<span class="number">.3</span>.0_3_szdt.jar:<span class="number">3.3</span><span class="number">.0_3</span>]</span><br><span class="line">	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:<span class="number">1.8</span><span class="number">.0_333</span>]</span><br><span class="line">	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:<span class="number">62</span>) ~[na:<span class="number">1.8</span><span class="number">.0_333</span>]</span><br><span class="line">	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:<span class="number">45</span>) ~[na:<span class="number">1.8</span><span class="number">.0_333</span>]</span><br><span class="line">	at java.lang.reflect.Constructor.newInstance(Constructor.java:<span class="number">423</span>) ~[na:<span class="number">1.8</span><span class="number">.0_333</span>]</span><br><span class="line">	at com.gbasedbt.jdbc.Driver.connect(Driver.java:<span class="number">252</span>) ~[gbasedbtjdbc_3<span class="number">.3</span>.0_3_szdt.jar:<span class="number">3.3</span><span class="number">.0_3</span>]</span><br></pre></td></tr></table></figure>





<h2 id="测试环境参考："><a href="#测试环境参考：" class="headerlink" title="测试环境参考："></a>测试环境参考：</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br></pre></td><td class="code"><pre><span class="line">[gbasedbt@wei2 ~]$ cd /home/gbasedbt/</span><br><span class="line">[gbasedbt@wei2 gbasedbt]$ ls</span><br><span class="line">csdk330_profile  g31.profile</span><br><span class="line">[gbasedbt@wei2 gbasedbt]$ . g31.profile </span><br><span class="line">gbasedbt:g31[/home/gbasedbt]$dbaccess sysuser -</span><br><span class="line"></span><br><span class="line">Database selected.</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">infor tables;</span></span><br><span class="line"></span><br><span class="line">  201: A syntax error has occurred.</span><br><span class="line">Error in line 1</span><br><span class="line">Near character position 1</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">info tables;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">Table name</span><br><span class="line"></span><br><span class="line">sysauth            sysdbsecadmauth    sysintauthusers    syssecpara        </span><br><span class="line">syssurrogategroups syssurrogates      systcxattributes   systcxusers       </span><br><span class="line">systrustedcontext  sysusercursess     sysuserext         sysuserlimits     </span><br><span class="line">sysusermap         sysuseros          </span><br><span class="line"></span><br><span class="line">Elapsed time: 0.615 sec</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash"><span class="keyword">select</span> * from sysusermap;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">username                         surrogate_id </span><br><span class="line"></span><br><span class="line">public                                      1</span><br><span class="line">dbtuser                                     1</span><br><span class="line">wangwei                                     1</span><br><span class="line">wangwei2                                    2</span><br><span class="line">wangwei3                                    2</span><br><span class="line"></span><br><span class="line">5 row(s) retrieved.</span><br><span class="line"></span><br><span class="line">Elapsed time: 0.052 sec</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash"><span class="keyword">select</span> * from syssurrogates ;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">surrogate_id  1</span><br><span class="line">os_username   daemon</span><br><span class="line">uid           0</span><br><span class="line">gid           0</span><br><span class="line">groupname     </span><br><span class="line">homedir       /home/gbase_daemon_dir</span><br><span class="line">userauth      ----------</span><br><span class="line"></span><br><span class="line">surrogate_id  2</span><br><span class="line">os_username   daemon</span><br><span class="line">uid           0</span><br><span class="line">gid           0</span><br><span class="line">groupname     </span><br><span class="line">homedir       </span><br><span class="line">userauth      ----------</span><br><span class="line"></span><br><span class="line">2 row(s) retrieved.</span><br><span class="line"></span><br><span class="line">Elapsed time: 0.060 sec</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash"></span></span><br><span class="line"><span class="language-bash"></span></span><br><span class="line">Database closed.</span><br><span class="line"></span><br><span class="line">gbasedbt:g31[/home/gbasedbt]$ls -l </span><br><span class="line">总用量 8</span><br><span class="line">-rwxr-xr-x. 1 gbasedbt gbasedbt 603 2月   3 16:28 csdk330_profile</span><br><span class="line">-rwxr-xr-x. 1 gbasedbt gbasedbt 768 2月   3 16:27 g31.profile</span><br><span class="line">gbasedbt:g31[/home/gbasedbt]$ls -l /home/gbase_daemon_dir</span><br><span class="line">ls: 无法访问/home/gbase_daemon_dir: 没有那个文件或目录</span><br><span class="line">gbasedbt:g31[/home/gbasedbt]$</span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E4%BC%9A%E8%AF%9D%E6%95%B0%E9%87%8F/" rel="tag">会话数量</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%86%85%E9%83%A8%E7%94%A8%E6%88%B7/" rel="tag">内部用户</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s库迁移到GBase8s"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8s%E5%BA%93%E8%BF%81%E7%A7%BB%E5%88%B0GBase8s/"
    >GBase8s库迁移到GBase8s</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E5%BA%93%E8%BF%81%E7%A7%BB%E5%88%B0GBase8s/" class="article-date">
  <time datetime="2023-05-10T01:25:36.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="GBase8s-库迁移到-GBase8s"><a href="#GBase8s-库迁移到-GBase8s" class="headerlink" title="GBase8s 库迁移到 GBase8s"></a>GBase8s 库迁移到 GBase8s</h1><p> 注意：这种通过dbschema迁移方法的，要把结构sql文件拆成2份，先建表然后直接导入数据，然后迁移后面的其他部分。应为多表约束有先后顺序，序列值好像不用管会记录当前值并alter。有跨库查询的这里不考虑。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">0、 全实例备份  安全先行</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">迁移目录</span></span><br><span class="line">mkdir -p /db/app02/trey_qy</span><br><span class="line">cd /db/app02/trey_qy</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">01 库结构</span></span><br><span class="line">dbschema -d picc95518 -ss ww_db.sql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">02 分离得到：建表语句、其他语句（不要用脚本最好手动拆分）</span></span><br><span class="line">cat ww_db.sql |sed -n &#x27;1,9714p&#x27; &gt; ww_db_tab.sql</span><br><span class="line">cat ww_db.sql |sed    &#x27;1,9714d&#x27; &gt; ww_db_oth.sql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">03 创建目标库，目标表</span></span><br><span class="line">dbaccess sysmaster &lt;&lt;!</span><br><span class="line">create database wwqydb in car3gdbs;</span><br><span class="line">!</span><br><span class="line">dbaccess wwqydb ww_db_tab.sql  #如果需要修改extend大小修改完成再执行。</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">04 确定表列表</span></span><br><span class="line">dbaccess picc95518 &lt;&lt;!</span><br><span class="line">unload to qy_tab_list.o</span><br><span class="line">select tabname from systables where tabid&gt;99 and tabtype=&#x27;T&#x27;;</span><br><span class="line">!</span><br><span class="line">dbaccess wwqydb &lt;&lt;!</span><br><span class="line">unload to qy_tab_list.n</span><br><span class="line">select tabname from systables where tabid&gt;99 and tabtype=&#x27;T&#x27;;</span><br><span class="line">!</span><br><span class="line">diff qy_tab_list.o qy_tab_list.n</span><br><span class="line">如果对比结果一样，正面表列表正确。</span><br><span class="line">cat qy_tab_list.o |sed &#x27;s/|$//&#x27; &gt; qy_tab_list</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">05 老库创建外部表，导出数据  -----------------------------------------  导出耗时： real    32:49.0    33分钟</span></span><br><span class="line">rm -fr   /db/app02/trey_qy/external_table</span><br><span class="line">mkdir -p /db/app02/trey_qy/external_table</span><br><span class="line"></span><br><span class="line">cat qy_tab_list |while read qytab</span><br><span class="line">do</span><br><span class="line">echo &quot;---  $qytab  -----------------------------------------------------------------------------------------&quot;</span><br><span class="line">time dbaccess picc95518 &lt;&lt;!</span><br><span class="line">drop            table $&#123;qytab&#125;_ext_a_b_c830;</span><br><span class="line">CREATE EXTERNAL TABLE $&#123;qytab&#125;_ext_a_b_c830 sameas $&#123;qytab&#125;</span><br><span class="line">USING</span><br><span class="line">(DATAFILES(&quot;DISK:/db/app02/trey_qy/external_table/$&#123;qytab&#125;.unl&quot;),</span><br><span class="line">FORMAT &#x27;DELIMITED&#x27;, DELIMITER &#x27;|&#x27;</span><br><span class="line">);</span><br><span class="line">set pdqpriority 96;</span><br><span class="line">--set isolation dirty read;</span><br><span class="line">set environment IFX_BATCHEDREAD_TABLE &#x27;1&#x27;;</span><br><span class="line">INSERT INTO $&#123;qytab&#125;_ext_a_b_c830  SELECT * FROM $&#123;qytab&#125;;</span><br><span class="line">!</span><br><span class="line">done</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">执行外部表导出</span></span><br><span class="line">nohup time sh wwexp.sh &amp;</span><br><span class="line"></span><br><span class="line">mv nohup.out nohup.out_exp</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">-----导出时的报错插曲</span></span><br><span class="line"><span class="meta prompt_">nx7420b#</span><span class="language-bash">[/db/app02/trey_qy]<span class="built_in">cat</span> nohup.out |<span class="built_in">sort</span> |<span class="built_in">uniq</span> -c |<span class="built_in">sort</span> |awk <span class="string">&#x27;$2~/:/&#x27;</span></span></span><br><span class="line">   2   602: Cannot open blob.</span><br><span class="line">   2   770: Bad fragment id specified. </span><br><span class="line"><span class="meta prompt_">nx7420b#</span><span class="language-bash">[/db/app02/trey_qy]<span class="built_in">cat</span> nohup.out |<span class="built_in">sort</span> |<span class="built_in">uniq</span> -c |<span class="built_in">sort</span> |grep -i err</span> </span><br><span class="line">   2 Error in line 1</span><br><span class="line"><span class="meta prompt_">nx7420b#</span><span class="language-bash">[/db/app02/trey_qy]</span></span><br><span class="line"></span><br><span class="line">大对象表：</span><br><span class="line">create table &quot;rb95518&quot;.app_biz_prplregist </span><br><span class="line">create table &quot;rb95518&quot;.app_biz_repsitdb </span><br><span class="line"></span><br><span class="line">select count(outcome) from app_biz_prplregist ;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">06 新库创建外部表，导入数据 ==================================================================</span></span><br><span class="line">cat qy_tab_list |while read qytab</span><br><span class="line">do</span><br><span class="line">echo &quot;---  $qytab  -----------------------------------------------------------------------------------------&quot;</span><br><span class="line">time dbaccess wwqydb &lt;&lt;!</span><br><span class="line">--drop            table $&#123;qytab&#125;_ext_a_b_c830;</span><br><span class="line">CREATE EXTERNAL TABLE $&#123;qytab&#125;_ext_a_b_c830 sameas $&#123;qytab&#125;</span><br><span class="line">USING</span><br><span class="line">(DATAFILES(&quot;DISK:/db/app02/trey_qy/external_table/$&#123;qytab&#125;.unl&quot;),</span><br><span class="line">FORMAT &#x27;DELIMITED&#x27;, DELIMITER &#x27;|&#x27;</span><br><span class="line">);</span><br><span class="line">set pdqpriority 96;</span><br><span class="line">--set isolation dirty read;</span><br><span class="line">set environment IFX_BATCHEDREAD_TABLE &#x27;1&#x27;;</span><br><span class="line">INSERT INTO $&#123;qytab&#125;  SELECT * FROM $&#123;qytab&#125;_ext_a_b_c830;</span><br><span class="line">!</span><br><span class="line">done</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">执行外部表导入</span></span><br><span class="line">--如果数据量大，可以把表列表拆分 出来，分成多个文件并行。</span><br><span class="line">nohup time sh wwimp.sh &amp;</span><br><span class="line"></span><br><span class="line">mv nohup.out nohup.out_imp</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">07 执行其他DDL语句</span></span><br><span class="line">vi ww_db_oth.sql</span><br><span class="line">  set pdqpriority 96;</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">--如果数据量大，可以把见索引的单独拿出来，分成多个文件并行。</span></span><br><span class="line">dbaccess wwqydb ww_db_oth.sql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">08 修改数据库日志模式</span></span><br><span class="line">ontape -s -U wwqydb -t /dev/null</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">09 做统计更新</span></span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%BF%81%E7%A7%BB/" rel="tag">迁移</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s约束Disable失效情况测试"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8s%E7%BA%A6%E6%9D%9FDisable%E5%A4%B1%E6%95%88%E6%83%85%E5%86%B5%E6%B5%8B%E8%AF%95/"
    >GBase8s约束Disable失效情况测试</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E7%BA%A6%E6%9D%9FDisable%E5%A4%B1%E6%95%88%E6%83%85%E5%86%B5%E6%B5%8B%E8%AF%95/" class="article-date">
  <time datetime="2023-05-10T01:24:20.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="五种常见的约束"><a href="#五种常见的约束" class="headerlink" title="五种常见的约束"></a>五种常见的约束</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">drop</span> <span class="keyword">table</span> t1;</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> t1(id serial <span class="keyword">primary</span> key, name <span class="type">char</span>(<span class="number">9</span>));</span><br><span class="line"></span><br><span class="line"><span class="keyword">drop</span> <span class="keyword">table</span> t2;</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> t2(</span><br><span class="line">	id <span class="type">int</span>,</span><br><span class="line">    wy <span class="type">int</span>,</span><br><span class="line">	fk <span class="type">int</span>,</span><br><span class="line">	wj <span class="type">int</span>,</span><br><span class="line">	qfj <span class="type">int</span></span><br><span class="line">);</span><br><span class="line"></span><br><span class="line"><span class="comment">--主键</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">table</span> t2 <span class="keyword">add</span> <span class="keyword">constraint</span>(<span class="keyword">primary</span> key (id)); </span><br><span class="line"><span class="comment">--唯一键</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">table</span> t2 <span class="keyword">add</span> <span class="keyword">constraint</span> <span class="keyword">unique</span> (wy) <span class="keyword">constraint</span> c_wy; </span><br><span class="line"><span class="comment">--非空键</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">table</span> t2 modify (fk <span class="type">int</span> <span class="keyword">not</span> <span class="keyword">null</span>); </span><br><span class="line"><span class="comment">--外键</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">table</span> t2 <span class="keyword">add</span> <span class="keyword">constraint</span> (<span class="keyword">FOREIGN</span> KEY (wj) <span class="keyword">REFERENCES</span> t1(id) <span class="keyword">constraint</span> c_wj);</span><br><span class="line"><span class="comment">--触发器</span></span><br><span class="line"><span class="comment">--drop trigger trig1; 删表后触发器自己就没有了。</span></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">trigger</span> trig1 <span class="keyword">insert</span> <span class="keyword">on</span> t2 after(</span><br><span class="line"> <span class="keyword">insert</span> <span class="keyword">into</span> t1(name) <span class="keyword">values</span> (&quot;in_new&quot;)</span><br><span class="line">);</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="这时t2的表结构是这样的"><a href="#这时t2的表结构是这样的" class="headerlink" title="这时t2的表结构是这样的"></a>这时t2的表结构是这样的</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">&#123; TABLE &quot;gbasedbt&quot;.t2 row size = 20 number of columns = 5 index size = 27 &#125;</span><br><span class="line"></span><br><span class="line">create table &quot;gbasedbt&quot;.t2 </span><br><span class="line">  (</span><br><span class="line">    id integer,</span><br><span class="line">    wy integer,</span><br><span class="line">    fk integer not null ,</span><br><span class="line">    wj integer,</span><br><span class="line">    qfj integer,</span><br><span class="line">    unique (wy)  constraint &quot;gbasedbt&quot;.c_wy,</span><br><span class="line">    primary key (id) </span><br><span class="line">  );</span><br><span class="line"></span><br><span class="line">revoke all on &quot;gbasedbt&quot;.t2 from &quot;public&quot; as &quot;gbasedbt&quot;;</span><br><span class="line"></span><br><span class="line">alter table &quot;gbasedbt&quot;.t2 add constraint (foreign key (wj) references </span><br><span class="line">    &quot;gbasedbt&quot;.t1  constraint &quot;gbasedbt&quot;.c_wj);</span><br><span class="line"></span><br><span class="line">create trigger &quot;gbasedbt&quot;.trig1 insert on &quot;gbasedbt&quot;.t2</span><br><span class="line">    after</span><br><span class="line">        (</span><br><span class="line">        insert into &quot;gbasedbt&quot;.t1 (name)  values (&#x27;in_new&#x27; ));</span><br></pre></td></tr></table></figure>

<h2 id="这时t2表的约束有那些"><a href="#这时t2表的约束有那些" class="headerlink" title="这时t2表的约束有那些"></a>这时t2表的约束有那些</h2> <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">select tabid from systables where tabname=&#x27;t2&#x27;;</span><br><span class="line">unload to /tmp/info select * from sysobjstate where tabid=142 order by 1;</span><br><span class="line"></span><br><span class="line">C|gbasedbt|n142_52|142|E|   非空</span><br><span class="line">C|gbasedbt|u142_48|142|E|  主键C</span><br><span class="line">C|gbasedbt|c_wj|142|E|     外键C</span><br><span class="line">C|gbasedbt|c_wy|142|E|     唯一键C</span><br><span class="line">I|gbasedbt| 142_48|142|E|   主键I</span><br><span class="line">I|gbasedbt| 142_50|142|E|   外键I</span><br><span class="line">I|gbasedbt| 142_51|142|E|   唯一键I</span><br><span class="line">T|gbasedbt|trig1|142|E|</span><br><span class="line"></span><br><span class="line">说明：142_50是tabid_约束id。</span><br><span class="line">约束可以这么查：select * from sysconstraints where constrname=&#x27;c_wj&#x27;;</span><br><span class="line">索引可以这么查：select * from sysindexes where idxname=&#x27; 142_50&#x27;;</span><br><span class="line"> 142_48|gbasedbt|142|U| |1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|1.0|0.0|0.0|  主键</span><br><span class="line"> 142_50|gbasedbt|142|D| |4|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|1.0|0.0|0.0|  外键</span><br><span class="line"> 142_51|gbasedbt|142|U| |2|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|1.0|0.0|0.0|  唯一键</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="Disable约束-x2F-索引-x2F-触发器"><a href="#Disable约束-x2F-索引-x2F-触发器" class="headerlink" title="Disable约束&#x2F;索引&#x2F;触发器"></a>Disable约束&#x2F;索引&#x2F;触发器</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">方法一</span></span><br><span class="line">	SET CONSTRAINTS c117_11, c117_12 DISABLED;</span><br><span class="line">	SET INDEXES idx_x1 DISABLED;</span><br><span class="line">	SET TRIGGERS upd_cust DISABLED;</span><br><span class="line">   </span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">方法二</span></span><br><span class="line">	SET CONSTRAINTS, INDEXES, TRIGGERS FOR t2 DISABLED; </span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">Results(结果):</span><br><span class="line"> Constraints are not checked</span><br><span class="line"> Triggers do not fire</span><br><span class="line"> Indexes are not updated or used for queries </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">结果全是D</span></span><br><span class="line">C|gbasedbt|n142_52|142|D|</span><br><span class="line">C|gbasedbt|u142_48|142|D|</span><br><span class="line">C|gbasedbt|c_wj|142|D|</span><br><span class="line">C|gbasedbt|c_wy|142|D|</span><br><span class="line">I|gbasedbt| 142_48|142|D|</span><br><span class="line">I|gbasedbt| 142_50|142|D|</span><br><span class="line">I|gbasedbt| 142_51|142|D|</span><br><span class="line">T|gbasedbt|trig1|142|D|</span><br></pre></td></tr></table></figure>

<h2 id="插入违规数据"><a href="#插入违规数据" class="headerlink" title="插入违规数据"></a>插入违规数据</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">insert into t2 values(1,2,3,4,5);</span><br><span class="line">insert into t2 values(1,2,3,4,5);</span><br><span class="line">--可以看到2行数据都插入成功了。</span><br></pre></td></tr></table></figure>

<h2 id="此时Enable约束-x2F-索引-x2F-触发器"><a href="#此时Enable约束-x2F-索引-x2F-触发器" class="headerlink" title="此时Enable约束&#x2F;索引&#x2F;触发器"></a>此时Enable约束&#x2F;索引&#x2F;触发器</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">SET CONSTRAINTS, INDEXES, TRIGGERS FOR t2 ENABLED;</span></span><br><span class="line"></span><br><span class="line">  371: 不可在已有重复的列上建立唯一索引。</span><br><span class="line">错误在 1 行</span><br><span class="line">第 48 字符</span><br><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash"></span></span><br><span class="line"><span class="language-bash"></span></span><br><span class="line">--可以看到启用失败了。</span><br></pre></td></tr></table></figure>

<h2 id="删除第2条重复的数据"><a href="#删除第2条重复的数据" class="headerlink" title="删除第2条重复的数据"></a>删除第2条重复的数据</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">delete from t2 where rowid=258;</span><br></pre></td></tr></table></figure>

<h2 id="此时Enable约束-x2F-索引-x2F-触发器-1"><a href="#此时Enable约束-x2F-索引-x2F-触发器-1" class="headerlink" title="此时Enable约束&#x2F;索引&#x2F;触发器"></a>此时Enable约束&#x2F;索引&#x2F;触发器</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">&gt; </span><span class="language-bash">SET CONSTRAINTS, INDEXES, TRIGGERS FOR t2 ENABLED;</span></span><br><span class="line"></span><br><span class="line">  525: 不能满足参考约束 c_wj。</span><br><span class="line"></span><br><span class="line">  111: ISAM 错误：找不到任何记录。</span><br><span class="line">错误在 1 行</span><br><span class="line">第 1 字符</span><br><span class="line"><span class="meta prompt_">&gt; </span></span><br></pre></td></tr></table></figure>

<h2 id="向t1表添加一条记录"><a href="#向t1表添加一条记录" class="headerlink" title="向t1表添加一条记录"></a>向t1表添加一条记录</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">insert into t1 values(4,&#x27;aa&#x27;);</span><br></pre></td></tr></table></figure>

<pre><code>    此时此时Enable约束/索引/触发器，成功。测试完成。
</code></pre>
<h2 id="小结："><a href="#小结：" class="headerlink" title="小结："></a>小结：</h2><pre><code>    约束禁用后，再启用数据库会检查约束情况，如果有不符合的数据会报错，启用失败。
</code></pre>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%BA%A6%E6%9D%9F/" rel="tag">约束</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
    <article
  id="post-GBase8s开启SqlTrace跟踪"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2023/05/10/GBase8s%E5%BC%80%E5%90%AFSqlTrace%E8%B7%9F%E8%B8%AA/"
    >GBase8s开启SqlTrace跟踪</a> 
</h2>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E5%BC%80%E5%90%AFSqlTrace%E8%B7%9F%E8%B8%AA/" class="article-date">
  <time datetime="2023-05-10T01:23:11.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
   
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <h2 id="1-开启SQL跟踪"><a href="#1-开启SQL跟踪" class="headerlink" title="1  开启SQL跟踪"></a>1  开启SQL跟踪</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">开启SQL跟踪的参数</span></span><br><span class="line">level = [off, low, med, high]</span><br><span class="line">ntraces = [跟踪的SQL语句的数量]</span><br><span class="line">size = [每个跟踪缓冲区的大小，以KB为单位]</span><br><span class="line">mode = [global, user]</span><br><span class="line">level=low, ntraces=10000, size=10, mode=global</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash">su - gbasedbt</span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash">dbaccess sysadmin -</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">高且全局</span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash">execute <span class="keyword">function</span> task (<span class="string">&quot;set sql tracing on&quot;</span>,30000, <span class="string">&quot;100&quot;</span>,<span class="string">&quot;high&quot;</span>,<span class="string">&quot;global&quot;</span>);<span class="string">&#x27;</span></span> </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">低且具体用户</span></span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash"><span class="string">execute function task(&quot;set sql tracing on&quot;, 20000, 10,&quot;low&quot;,&quot;user&quot;);</span></span> </span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="string">指定会话</span></span></span><br><span class="line"><span class="meta prompt_">Shell&gt; </span><span class="language-bash"><span class="string">execute function task(&quot;set sql user tracing on&quot;,11044);</span></span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="2-执行语句"><a href="#2-执行语句" class="headerlink" title="2  执行语句"></a>2  执行语句</h2><p>​		……或者运行业务。</p>
<h2 id="3-查询跟踪情况用命令"><a href="#3-查询跟踪情况用命令" class="headerlink" title="3 查询跟踪情况用命令"></a>3 查询跟踪情况用命令</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">onstat -g his</span><br></pre></td></tr></table></figure>

<h2 id="3-查询耗时最多的语句"><a href="#3-查询耗时最多的语句" class="headerlink" title="3 查询耗时最多的语句"></a>3 查询耗时最多的语句</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">first</span> <span class="number">500</span> sql_runtime,sql_executions,sql_statement </span><br><span class="line"><span class="keyword">from</span> </span><br><span class="line">	syssqltrace t,</span><br><span class="line">	syssqltrace_iter i</span><br><span class="line"><span class="keyword">where</span> t.sql_id <span class="operator">=</span> i.sql_id </span><br><span class="line"><span class="keyword">order</span> <span class="keyword">by</span> <span class="number">1</span> <span class="keyword">desc</span>;</span><br></pre></td></tr></table></figure>

<h2 id="4-关闭SQL跟踪"><a href="#4-关闭SQL跟踪" class="headerlink" title="4  关闭SQL跟踪"></a>4  关闭SQL跟踪</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo &#x27; execute function sysadmin:task(&quot;SET SQL TRACING OFF&quot;); &#x27; | dbaccess sysadmin</span><br></pre></td></tr></table></figure>



<p>参数没改，重启trace失效：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SQL Tracing and EXPLAIN Plan Configuration Parameters</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">EXPLAIN_STAT - Enables (1) or disables (0) including the Query</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               Statistics section <span class="keyword">in</span> the EXPLAIN output file</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">SQLTRACE     - Configures SQL tracing. The format is:</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               SQLTRACE level=(low|med|high),ntraces=&lt;<span class="comment">#&gt;,size=&lt;#&gt;,</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               mode=(global|user)</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               Example:</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">               SQLTRACE level=low,ntraces=1000,size=2,mode=global</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">##################################################################</span></span></span><br><span class="line"></span><br><span class="line">EXPLAIN_STAT 1</span><br><span class="line"></span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SqlTrace/" rel="tag">SqlTrace</a></li></ul>

    </footer>
  </div>

   
   
  
</article>

    
  </article>
  

  
  <nav class="page-nav">
    
    <a class="extend prev" rel="prev" href="/page/2/">上一页</a><a class="page-number" href="/">1</a><a class="page-number" href="/page/2/">2</a><span class="page-number current">3</span><a class="page-number" href="/page/4/">4</a><a class="page-number" href="/page/5/">5</a><a class="page-number" href="/page/6/">6</a><a class="extend next" rel="next" href="/page/4/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023-2024
        <i class="ri-heart-fill heart_icon"></i> Wang Wei
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ww.ico" alt="朝花夕拾"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>